Skip to content

Custom handling for push receipts, opens, dismissals, and key-value pairs via Broadcast Receiver

Braze also broadcasts custom intents when push notifications are received, opened, or dismissed. If you have a specific use case for these scenarios (such as the need to listen for custom key-value pairs or proprietary handling of deep links), you will need to listen for these intents by creating a custom BroadcastReceiver.

Step 1: Register your BroadcastReceiver

Register your custom BroadcastReceiver to listen for Braze push opened and received intents in your AndroidManifest.xml :

Step 2: Create Your BroadcastReceiver

Your receiver should handle intents broadcast by Braze and launch your activity with them:

  • It should subclass BroadcastReceiver and override onReceive().
  • The onReceive() method should listen for intents broadcast by Braze.
    • A NOTIFICATION_RECEIVED intent will be received when a push notification arrives.
    • A NOTIFICATION_OPENED intent will be received when the user clicks a push notification.
    • An NOTIFICATION_DELETED intent will be received when a push notification is dismissed (swiped away) by the user.
  • It should perform your custom logic for each of these cases. If your receiver will open deep links, be sure to turn off automatic deep link opening by setting com_braze_handle_push_deep_links_automatically to false in your braze.xml.

For a detailed custom receiver example, see the following code snippets:

Step 3: Access custom key-value pairs

Custom key-value pairs sent either via the dashboard or the messaging APIs will be accessible in your custom broadcast receiver for whatever purpose you choose:

HOW HELPFUL WAS THIS PAGE?
New Stuff!