In-app messaging integration
Learn how to set up iOS, Android, and FireOS In-App Messages (IAM) for the Xamarin platform.
Prerequisites
To use this feature, you’ll need to integrate the Braze SDK for Xamarin.
Integrating in-app messaging
To see an example, check out our sample Xamrin app on GitHub.
Step 1: Set up in-app message registration
Every activity in your app must be registered with the BrazeInAppMessageManager
class. To automatically register in-app messages using the activity lifecycle callback integration, add the following code to the onCreate()
method in your Application
class:
1
2
3
4
5
6
7
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
registerActivityLifecycleCallbacks(new BrazeActivityLifecycleCallbackListener());
}
}
1
2
3
4
5
6
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
registerActivityLifecycleCallbacks(BrazeActivityLifecycleCallbackListener())
}
}
For the full list of available parameters, see BrazeActivityLifecycleCallbackListener
.
Step 2: Set up a blocklist manager (optional)
To prevent certain activities from displaying in-app messages, use the activity lifecycle callback integration. The following sample code adds two activities to the in-app message registration blocklist: SplashActivity
and SettingsActivity
.
1
2
3
4
5
6
7
8
9
10
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Set<Class> inAppMessageBlocklist = new HashSet<>();
inAppMessageBlocklist.add(SplashActivity.class);
inAppMessageBlocklist.add(SettingsActivity.class);
registerActivityLifecycleCallbacks(new BrazeActivityLifecycleCallbackListener(inAppMessageBlocklist));
}
}
1
2
3
4
5
6
7
8
9
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val inAppMessageBlocklist = HashSet<Class<*>>()
inAppMessageBlocklist.add(SplashActivity::class.java)
inAppMessageBlocklist.add(SettingsActivity::class.java)
registerActivityLifecycleCallbacks(BrazeActivityLifecycleCallbackListener(inAppMessageBlocklist))
}
}
To see an example, check out our sample Xamrin app on GitHub.
To use Braze’s default in-app message UI, first create a new BrazeInAppMessageUI
:
1
public static BrazeInAppMessageUI? inAppMessageUI = new BrazeInAppMessageUI();
Then, register the BrazeInAppMessageUI
as the in-app message presenter when setting up your Braze instance:
1
braze.InAppMessagePresenter = inAppMessageUI;
Now you can present new in-app messages using Braze’s default in-app message UI.
GIF Support
You can add animated GIFs to your in-app messages using the native Braze Android SDK. By default, the Android SDK uses HTML in-app messages to display GIFs.
For all other in-app message types, you’ll need to use a custom image library. To learn more, see Android In-App Messaging: GIFs.
You can add animated GIFs to your in-app messages using the native Braze Swift SDK. By default, all Braze in-app messages support GIFs. For a full walkthrough, see Tutorial: GIF Support for Swift In-App Messages.