After you have successfully instrumented Braze as a destination in RudderStack, follow this guide to correctly send your events to Braze in device mode.
Add Braze integration
Make sure to add the Braze integration to your project before sending events to Braze in device mode.
Depending on your integration platform, follow these steps:
Open the Podfile of your project and add the following:
pod'Rudder-Braze'
Run the pod install command.
Change the SDK initialization to the following snippet:
In mobile device mode, that is, when using Android, iOS, React Native, or Flutter as source, you need to pass externalId in your identify events. Otherwise, Braze uses userId to identify the user.
Braze gives first preference to the externalId field in the identify event to identify the user. If externalId is absent, it falls back to the userId field.
The following code snippet shows how to add an externalId to your identify event using the React Native SDK:
Make sure to send the identify event containing the externalId before sending any subsequent track events. That way, RudderStack is able to successfully persist the externalId information in all the future events.
If you are sending events to Braze in device mode, you can save costs by deduplicating your identify calls. To do so, enable the Deduplicate Traits dashboard setting. RudderStack then sends only the changed or modified attributes (traits) to Braze.
RudderStack recommends reviewing Braze’s data points policy to fully understand how this functionality can help you avoid data overages.
Advanced features
This section covers some advanced Braze operations that you can perform using RudderStack.
Send push notification events
Depending on your iOS SDK version, follow these steps to send push notification events to Braze:
You must assign the delegate object using center.delegate = self synchronously before your app finishes launching - preferably in application:didFinishLaunchingWithOptions.
// - Register the device token with Braze
-(void)application:(UIApplication*)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{if([RudderBrazeFactoryinstance].integration){[[RudderBrazeFactoryinstance].integrationdidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];}}
Make sure that RudderBrazeFactory is initialized before making calls to this push API.
Since the Braze push API is designed as an instance method, it relies on the SDK that is correctly initialized beforehand. To do this, you can utilize the dispatch_after API.
Enable push handling:
// - Add support for silent notification
-(void)application:(UIApplication*)applicationdidReceiveRemoteNotification:(NSDictionary*)userInfofetchCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler{if([RudderBrazeFactoryinstance].integration){[[RudderBrazeFactoryinstance].integrationdidReceiveRemoteNotification:userInfofetchCompletionHandler:completionHandler];}}// - Add support for push notifications
-(void)userNotificationCenter:(UNUserNotificationCenter*)centerdidReceiveNotificationResponse:(UNNotificationResponse*)responsewithCompletionHandler:(void(^)(void))completionHandler{if([RudderBrazeFactoryinstance].integration){[[RudderBrazeFactoryinstance].integrationdidReceiveNotificationResponse:responsewithCompletionHandler:completionHandler];}}// - Add support for displaying push notification when the app is currently running in the foreground
-(void)userNotificationCenter:(UNUserNotificationCenter*)centerwillPresentNotification:(UNNotification*)notificationwithCompletionHandler:(void(^)(UNNotificationPresentationOptions))completionHandler{if(@available(iOS14,*)){completionHandler(UNNotificationPresentationOptionList|UNNotificationPresentationOptionBanner);}else{completionHandler(UNNotificationPresentationOptionAlert);}}
Braze recommends invoking the push integration code within the application’s main thread.
Add the following code to your AppDelegate file under the didFinishLaunchingWithOptions method:
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.