Integration
Step 1: Braze In-App Message Manager Registration
In-App Message display is managed by the AppboyInAppMessageManager
class. Every activity in your app must be registered with the AppboyInAppMessageManager
to allow it to add in-app message views to the view hierarchy. There are two ways to accomplish this:
Activity Lifecycle Callback Integration (Recommended)
The Activity Lifecycle Callback Integration handles in-app message registration automatically, no extra integration is required. This is the recommended integration for handling in-app message registration.
Manual In-App Message Registration
A manual in-app message registration requires 3 steps.
If you did the activity lifecycle integration, then you should not do a manual in-app message integration.
- In your
Application.onCreate()
,ensureSubscribedToInAppMessageEvents()
should be called.
1
AppboyInAppMessageManager.getInstance().ensureSubscribedToInAppMessageEvents(context);
- In every activity where in-app messages can be shown,
registerInAppMessageManager()
should be called in that activity’sonResume()
.
1
2
3
4
5
6
7
@Override
public void onResume() {
super.onResume();
// Registers the AppboyInAppMessageManager for the current Activity. This Activity will now listen for
// in-app messages from Braze.
AppboyInAppMessageManager.getInstance().registerInAppMessageManager(activity);
}
- In every activity where
registerInAppMessageManager()
was called,unregisterInAppMessageManager()
should be called in that activity’sonPause()
.
1
2
3
4
5
6
@Override
public void onPause() {
super.onPause();
// Unregisters the AppboyInAppMessageManager for the current Activity.
AppboyInAppMessageManager.getInstance().unregisterInAppMessageManager(activity);
}