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 GoNative JavaScript Bridge function gonative.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

↔️GoNative JavaScript Bridge

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

Prompt for Push Notification Permission

Request Push Notification permission, will show 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.

Provide a callback function or otherwise returns a promise.

↔️GoNative JavaScript Bridge

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

Check Push Notification Permission

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

Provide a callback function or otherwise returns a promise.

↔️GoNative JavaScript Bridge

gonative.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.

↔️GoNative JavaScript Bridge

gonative.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 - Opens app when notification is clicked, does nothing if 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 gonative.braze.changeUser({userId:String}).