Looking for the out-of-the-box Push developer integration guide? Find it here.
Push Notification 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! Please 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!
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 example below shows a push notification after a user has completed a specific task (Braze LAB 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.
To set up a personalized push in the dashboard, you must register the specific category you would like to be displayed. Set the appropriate user attributes you would like 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 with the Braze API (Recommended)
Logging analytics can only be done in real-time with the help of the customer’s server hitting Braze’s API users/track endpoint. To log analytics, send down the
braze_id value in the key-value pairs field (as seen in the screenshot below) to identify which user profile to update.
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.