registerInAppCallback

Registers a callback for InApp messages.

Call this method after Mindbox.init. The SDK holds a strong reference to inAppCallback, so the callback persists until explicitly replaced or removed via unregisterInAppCallback.

Calling this method again replaces the previously registered callback.

Application-level callback (recommended): Register once in Application.onCreate with a callback that does not reference any Activity. No cleanup needed.

class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Mindbox.init(...)
Mindbox.registerInAppCallback(MyGlobalInAppCallback())
}
}

Per-screen callback: If different screens require different callback behavior and the callback captures an Activity reference, use onResume/onPause — not onCreate/onDestroy. Android guarantees that onPause of the current Activity is called before onResume of the next, so callbacks never overlap and the Activity reference is always cleared before the Activity can be garbage-collected.

override fun onResume() {
super.onResume()
Mindbox.registerInAppCallback(myScreenCallback)
}
override fun onPause() {
super.onPause()
Mindbox.unregisterInAppCallback()
}

Parameters

inAppCallback

the callback implementation to register