In-App Lifecycle Callbacks

Since Reteno SDK 2.0.2 you can subscribe to In-App messages lifecycle.

You get callbacks:

  • before In-App message is displayed
  • right after In-App message is displayed
  • before In-App message is closed
  • after In-App message is closed
  • if an error during displaying In-App message occurred

In these callbacks you also receive a data model which contains information whether In-App message was displayed via display rules or push notification click, ID or interaction ID of In-App message, and some other data which may be useful.

To subscribe to In-App message lifecycle callbacks you have to call setInAppLifecycleCallback(InAppLifecycleCallback) from Reteno interface.

val reteno = (application as RetenoApplication).getRetenoInstance()
reteno.setInAppLifecycleCallback(object : InAppLifecycleCallback {
    override fun beforeDisplay(inAppData: InAppData) {
        // ...
    }

    override fun onDisplay(inAppData: InAppData) {
        // ...
    }

    override fun beforeClose(closeData: InAppCloseData) {
        // ...
    }

    override fun afterClose(closeData: InAppCloseData) {
        // ...
    }

    override fun onError(errorData: InAppErrorData) {
        // ...
    }
})
Reteno reteno = ((RetenoApplication) getApplication()).getRetenoInstance();
reteno.setInAppLifecycleCallback(new InAppLifecycleCallback() {
    @Override
    public void beforeDisplay(@NonNull InAppData inAppData) {
        // ...
    }

    @Override
    public void onDisplay(@NonNull InAppData inAppData) {
        // ...
    }

    @Override
    public void beforeClose(@NonNull InAppCloseData closeData) {
        // ...
    }

    @Override
    public void afterClose(@NonNull InAppCloseData closeData) {
        // ...
    }

    @Override
    public void onError(@NonNull InAppErrorData errorData) {
        // ...
    }
});

To unsubscribe pass a null to setInAppLifecycleCallback function.