Skip to main content

Overlay Integration

Overview

This guide walks you through integrating overlays into your Maestro Android SDK implementation. The MaestroOverlays() composable allows display of celebratory overlays when a user wins a bet or a Fantasy event happens.

Integration Steps

1. Initialize the Maestro SDK with a Delegate

Initialize the Maestro SDK with a delegate conforming to MaestroEventDelegate:

val sdk = MaestroSDK.configure(
context = applicationContext,
maestroEventDelegate = this,
params = MaestroSDKParameters(
siteId = "your-site-id",
eventData = null,
),
)

2. Add MaestroOverlays to Your UI

Use the MaestroOverlays() composable in your Jetpack Compose UI:

@Composable
fun MyScreen() {
val overlayVM = viewModel(
modelClass = MaestroOverlayViewModel::class.java,
factory = MaestroOverlayViewModelFactory(sdk = sdk),
key = "Overlay" + sdk.hashCode().toString(),
)
MaestroOverlays(
viewModel = overlayVM,
)

}

Best Practices

  • ViewModel Scoping: Ensure the overlay ViewModel is scoped correctly to the SDK instance by using a key that corresponds to the SDK instance's hash code
  • Lifecycle Awareness: Manage overlay state across configuration changes