Braze

Configuration

Update the following parameters on the Push Notifications tab under Braze:

{
  "active": true | false,
  "autoRegister": true | false, // if true push permission will be requested automatically
  "iosApiKey": STRING,
  "iosEndpointKey": STRING, // "sdk.xyz-##.braze.com"
  "androidApiKey": STRING,
  "androidEndpointKey": STRING, // "sdk.xyz-##.braze.com"
  "firebaseSenderId": STRING
}

Enabling Push Notifications

Enable using Braze In-App Messaging functionality documented at https://www.braze.com/docs/user_guide/message_building_by_channel/push/push_primer_messages/.

Or enable using the Median JavaScript Bridge function median.braze.promptNotification() documented below.

Alternatively you may set autoRegister to true in the configuration JSON as indicated above.

Deep Linking

Set up Deep Linking within your app and notification links will automatically open directly into your app.

JavaScript Bridge Functions

Change User

Register a new user or login an existing user

↔️Median JavaScript Bridge

median.braze.changeUser({'userId': STRING})

Prompt for Push Notification Permission

This prompt requests Push Notification permission by showing a dialog for users to confirm permission. For Android, the dialog is only shown on Android 13 and above. Android 12 and below will always be granted without user intervention.

For this command, provide a callback function or otherwise it returns a promise.

↔️Median JavaScript Bridge

median.braze.promptNotification({'callback': function})
// Return value:
{
  "granted": true | false
}

Check Push Notification Permission

This checks if the user has granted Push Notification permission. For Android, the permission must be checked first to ensure that Push Notification will show on Android 13 and above. For Android 12 and below, permission will always be granted.

For this command, provide a callback function or otherwise it returns a promise.

↔️Median JavaScript Bridge

median.braze.notificationEnabled({'callback': function})
// Return value:
{
  "granted": true | false
}

Track Custom Event

Send a Custom Event to Braze. Custom Events must be added in the Braze Dashboard.

↔️Median JavaScript Bridge

median.braze.logCustomEvent("YOUR-EVENT-NAME", {
  "key1": value1,
  "key2": value2,
  ...
});

Testing Notifications and Deep Linking

  1. On the Braze Dashboard, navigate to the Campaigns tab under Engagement, then click Create Campaign and select Push Notification

  2. Scroll down and click Android Push or iOS Push accordingly.

  3. Input a Title and Message then scroll down and select the type of notification Push Notification Body.
    Open App - This opens your app when notification is clicked, or does nothing if the App is already opened.
    Deep Link Into Application - Input a URL which your app will load when the notification is clicked by the user. Ensure that Deep Linking is correctly configured for your app.

  4. Send the notification to a test user by navigating to the Test tab and adding the test users. Then, click Send Test.
    Note: So that users are listed, ensure you call median.braze.changeUser({userId:String}).