Migration
Braze API mapping
Braze SDK calls and the Herald calls that replace them, in Swift and Kotlin, with the calls that have no equivalent.
Use these tables to replace Braze SDK calls with Herald calls during a migration. Every Herald call listed exists in version 0.2.0; full signatures are on iOS API and Android API. Where a Braze call has no equivalent, the table says so.
Herald has no instance to keep: call Herald.shared on iOS and the Herald object on Android.
Swift
| Area | Braze | Herald |
|---|---|---|
| Setup | Braze(configuration: Braze.Configuration(apiKey:endpoint:)) | Herald.configure(appKey:endpoint:options:) |
| Setup | configuration.sessionTimeout | options.foregroundSessionTimeout and options.backgroundSessionTimeout |
| Setup | configuration.triggerMinimumTimeInterval | options.inAppMinimumInterval |
| Setup | configuration.logger.level | options.logLevel |
| Identity | braze.changeUser(userId:) | identify(userId:traits:) |
| Identity | braze.set(sdkAuthenticationSignature:) | setUserToken(_:) |
| Identity | braze.user.add(alias:label:) | No equivalent |
| Attributes | braze.user.setCustomAttribute(key:value:) | setAttribute(_:_:) or setAttributes(_:) |
| Attributes | braze.user.set(firstName:) and other standard fields | setAttribute("first_name", ...) with a key you choose |
| Attributes | braze.user.set(email:) | setEmail(_:) |
| Attributes | braze.user.set(phoneNumber:) | setPhone(_:) (E.164) |
| Attributes | braze.user.unsetCustomAttribute(key:) | setAttribute(key, nil) stores an explicit null |
| Attributes | braze.user.incrementCustomUserAttribute(key:by:) | No equivalent; send the new value |
| Attributes | braze.user.addToCustomAttributeArray(key:value:) | No equivalent; send the full array |
| Attributes | braze.user.setLastKnownLocation(latitude:longitude:) | setLocation(latitude:longitude:) |
| Subscriptions | braze.user.set(emailSubscriptionState:) | setSubscription(.email, _:) |
| Subscriptions | braze.user.set(pushNotificationSubscriptionState:) | setSubscription(.push, _:) |
| Events | braze.logCustomEvent(name:properties:) | track(_:properties:) |
| Events | braze.logPurchase(productID:currency:price:quantity:properties:) | trackPurchase(productId:price:currency:quantity:properties:) |
| Push | braze.notifications.register(deviceToken:) | setPushToken(_:) |
| Push | braze.notifications.handleUserNotification(response:withCompletionHandler:) | handleNotificationResponse(_:), then call the completion handler yourself |
| Push | Braze.Notifications.categories | registerPushCategories(_:) with your own HeraldPushCategory values |
| Push | BrazeNotificationService.NotificationService subclass in a notification service extension | HeraldNotificationService |
| Content cards | braze.contentCards.requestRefresh() | refreshContentCards() |
| Content cards | braze.contentCards.cards | contentCards.cards |
| Content cards | card.context?.logImpression() | logImpression(card) |
| Content cards | card.context?.logClick() | logClick(card) |
| Content cards | card.context?.logDismissed() | logDismissal(card) |
| Content cards | BrazeContentCardUI.ViewController(braze:) | ContentCardFeed() (SwiftUI) |
| In-app | braze.inAppMessagePresenter = BrazeInAppMessageUI() | Herald.useDefaultInAppUI() |
| In-app | BrazeInAppMessageUIDelegate.inAppMessage(_:displayChoiceForMessage:) | InAppMessageDelegate.shouldDisplay(_:) |
| In-app | .now, .reenqueue, .discard | .display, .later, .discard |
| Data control | braze.enabled = false | setEnabled(false) |
| Data control | braze.wipeData() | wipeData() |
| Data control | braze.requestImmediateDataFlush() | flush() |
| Sign-out | changeUser to another ID | reset() returns the device to anonymous |
Kotlin
| Area | Braze | Herald |
|---|---|---|
| Setup | Braze.configure(context, BrazeConfig) or braze.xml | Herald.configure(context, appKey, endpoint, options) |
| Setup | BrazeActivityLifecycleCallbackListener | Not needed; configure registers its own lifecycle callbacks |
| Identity | Braze.getInstance(context).changeUser(userId) | Herald.identify(userId, traits) |
| Identity | changeUser(userId, sdkAuthSignature) or setSdkAuthenticationSignature(signature) | Herald.identify(userId) then Herald.setUserToken(token) |
| Attributes | currentUser?.setCustomUserAttribute(key, value) | Herald.setAttribute(key, value) |
| Attributes | currentUser?.setEmail(email) | Herald.setEmail(email) |
| Attributes | currentUser?.setPhoneNumber(phone) | Herald.setPhone(phone) (E.164) |
| Attributes | currentUser?.incrementCustomUserAttribute(key, by) | No equivalent; send the new value |
| Attributes | currentUser?.addToCustomAttributeArray(key, value) | No equivalent; send the full list |
| Attributes | currentUser?.setLastKnownLocation(latitude, longitude, altitude, accuracy) | Herald.setLocation(latitude, longitude) |
| Subscriptions | currentUser?.setEmailNotificationSubscriptionType(type) | Herald.setSubscription(SubscriptionChannel.EMAIL, state) |
| Subscriptions | currentUser?.setPushNotificationSubscriptionType(type) | Herald.setSubscription(SubscriptionChannel.PUSH, state) |
| Events | logCustomEvent(name, properties) | Herald.track(name, properties) |
| Events | logPurchase(productId, currencyCode, price, quantity) | Herald.trackPurchase(productId, price, currency, quantity) |
| Push | BrazeFirebaseMessagingService | HeraldMessagingService (registered by herald-fcm) |
| Push | BrazeFirebaseMessagingService.handleBrazeRemoteMessage(context, message) | HeraldNotifications.handleRemoteMessage(context, message) |
| Push | registeredPushToken = token | Herald.setPushToken(token) (herald-fcm does it for you) |
| Push | Notification open handling | Herald.handleNotificationIntent(intent) in onCreate and onNewIntent |
| Content cards | requestContentCardsRefresh() | Herald.refreshContentCards() |
| Content cards | subscribeToContentCardsUpdates(subscriber) | Collect Herald.contentCards (a StateFlow) |
| Content cards | card.logImpression(), card.logClick() | Herald.logImpression(card), Herald.logClick(card) |
| Content cards | card.isDismissed = true | Herald.logDismissal(card) |
| Content cards | ContentCardsFragment or the Compose ContentCardsList | ContentCardFeed() (Compose) |
| In-app | BrazeInAppMessageManager default display | HeraldInAppPresenter.install() |
| In-app | IInAppMessageManagerListener.beforeInAppMessageDisplayed | InAppMessageDelegate.shouldDisplay |
| In-app | DISPLAY_NOW, DISPLAY_LATER, DISCARD | DISPLAY, LATER, DISCARD |
| Data control | Braze.disableSdk(context), Braze.enableSdk(context) | Herald.setEnabled(false), Herald.setEnabled(true) |
| Data control | Braze.wipeData(context) | Herald.wipeData() |
| Data control | requestImmediateDataFlush() | Herald.flush() |
| Sign-out | changeUser to another ID | Herald.reset() |
Behavior differences to check
- Token order. Call
identifyfirst, thensetUserToken. Identifying a different user clears the previous token. - Verification is on by default. A new connection requires a user token for every request that names a user. Plan the backend route before you ship.
- Push permission.
requestPushAuthorizationon both platforms shows the prompt and records the subscription, so you do not set the subscription yourself after the prompt. - In-app timing. A message that cannot show at once is kept and shown later, and the delegate is asked each time it is about to appear. See Triggers and delivery rules.
- Properties. iOS properties are
HeraldValueliterals. Android properties are aMap<String, Any?>.