Looking for the basic push notification developer integration guide? Find it here.
Advanced implementation guide
This optional and advanced implementation guide covers ways to leverage a custom FirebaseMessagingService subclass to get the most out of your push messages. Included is a custom use case built by our team, accompanying code snippets, and guidance on logging analytics. Visit our Braze Demo Repository here! Note that this implementation guide is centered around a Kotlin implementation, but Java snippets are provided for those interested.
Custom notification layout
Braze notifications are sent as data messages, which means that your application will always have a chance to respond and perform behavior accordingly, even in the background (this is in contrast to notification messages, which can be handled automatically by the system when your app is in the background). As such, your application will have a chance to customize the experience by, for example displaying personalized UI elements within the notification delivered to the notification tray. While implementing push in this way may be unfamiliar to some, one of our well-known features at Braze, Push Stories, are a prime example of using custom view components to create an engaging experience!
Requirements
Android imposes some limitations on what components can be used to implement custom notification views. Notification view layouts must only contain View objects compatible with the RemoteViews framework.
Personalized push notifications
Push notifications can display user-specific information inside a custom view hierarchy. The following example shows a push notification after a user has completed a specific task (Braze Learning course) and is now encouraged to expand this notification to check their progress. The information provided here is user-specific and can be fired off as a session is completed or specific user action is taken by leveraging an API trigger.
Dashboard configuration
To set up a personalized push in the dashboard, you must register the specific category you want to be displayed. Set the appropriate user attributes you want the message to show within the key-value pairs using standard Liquid. These views can be personalized based on specific user attributes of a specific user profile.
Ready to log analytics?
Visit the following section to better understand how the flow of data should look.
Logging analytics
Logging with the Braze API (recommended)
Logging analytics can only be done in real-time with the help of the customer’s server hitting our /users/track
endpoint. To log analytics, send down the braze_id
value in the key-value pairs field (as seen in the following screenshot) to identify which user profile to update.
Logging manually
Logging manually can be achieved by logging whatever elements you wish from either within your FirebaseMessagingService.onMessageReceived
implementation or from within your startup activity, based on the extras present in the payload. However, an important caveat to remember is that your FirebaseMessagingService
subclass must finish execution within 10 seconds of invocation to avoid being flagged or terminated by the Android system.