Inline In-App
An inline in-app message is a view component embedded directly in a page's layout. This component renders specific content based on the provided viewId.
The SDK supports multiple inline messages on the same page.
Inline messages do not share the pause setting with In-App Overlays, which means you can load new inline messages even if isPaused() returns true.
On Android and KMP, inline in-app messages use Compose. On iOS, they use UIViewController.
Using Inline In-App Messages
- Android
- Kotlin Multiplatform
- iOS
- Web
Use the InlineInApp composable in your Compose code:
import com.sap.ec.mobileengage.inapp.view.InlineInAppView
@Composable
fun MyExampleView() {
InlineInAppView(viewId = viewId)
}
If your Android app isn't using Compose, you can still embed inline in-app messages by using a ComposeView. See: Using Compose Views in Non-Compose Android Apps.
Use the InlineInApp composable in your shared Compose code:
import com.sap.ec.mobileengage.inapp.view.InlineInAppView
@Composable
fun MyExampleView() {
InlineInAppView(viewId = viewId)
}
Get a UIViewController containing the message list:
// In your view controller or SwiftUI view
let inlineInAppViewController = EngagementCloud.shared.inApp.InlineInAppViewController(viewId: viewId)
// Present or embed the view controller
navigationController?.pushViewController(inlineInAppViewController, animated: true)
Use UIViewControllerRepresentable to embed in SwiftUI:
struct InlineInAppViewWrapper: UIViewControllerRepresentable {
var viewId: String?
func makeUIViewController(context: Context) -> UIViewController {
EngagementCloud.shared.inApp.InlineInAppViewController(viewId: viewId)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
// Usage in a SwiftUI view
struct ContentView: View {
var body: some View {
InlineInAppViewWrapper(viewId: viewId)
}
}
This feature is not supported on Web.
Callbacks
InlineInAppView supports two optional callbacks to track lifecycle events:
onLoaded- Called when the message finishes loading and is ready to displayonClose- Called when the message is closed (by user)
For tracking interaction events like button clicks, use the EngagementCloud.events API to subscribe to SDK events globally.
- Android
- Kotlin Multiplatform
- iOS
- Web
import com.sap.ec.mobileengage.inapp.view.InlineInAppView
@Composable
fun MyExampleView() {
InlineInAppView(
viewId = "my-view-id",
onLoaded = {
println("Inline in-app message loaded successfully")
},
onClose = {
println("Inline in-app message closed")
}
)
}
import com.sap.ec.mobileengage.inapp.view.InlineInAppView
@Composable
fun MyExampleView() {
InlineInAppView(
viewId = "my-view-id",
onLoaded = {
println("Inline in-app message loaded successfully")
},
onClose = {
println("Inline in-app message closed")
}
)
}
let inlineInAppViewController = EngagementCloud.shared.inApp.InlineInAppViewController(
viewId: "my-view-id",
onLoaded: {
print("Inline in-app message loaded successfully")
},
onClose: {
print("Inline in-app message closed")
}
)
// Present or embed the view controller
navigationController?.pushViewController(inlineInAppViewController, animated: true)
For SwiftUI:
struct InlineInAppViewWrapper: UIViewControllerRepresentable {
var viewId: String
var onLoaded: (() -> Void)?
var onClose: (() -> Void)?
func makeUIViewController(context: Context) -> UIViewController {
EngagementCloud.shared.inApp.InlineInAppViewController(
viewId: viewId,
onLoaded: onLoaded,
onClose: onClose
)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
// Usage
struct ContentView: View {
var body: some View {
InlineInAppViewWrapper(
viewId: "my-view-id",
onLoaded: {
print("Message loaded")
},
onClose: {
print("Message onClose")
}
)
}
}
This feature is not supported on Web.