Learn how to use the additive namespaced API in Reteno React Native SDK 3.0.0 and later.
Namespaced API
Available since reteno-react-native-sdk v3.0.0.
Every SDK method has always been exported as a flat, top-level function ā setUserAttributes, setOnRetenoPushReceivedListener, logEcomEventOrderCreated, and so on. That flat form is unchanged and stays the canonical, fully supported API ā nothing in this page deprecates it.
Starting with v3.0.0, the same functions are additionally grouped into seven namespaced objects: user, push, events, inApp, inbox, recommendations, ecommerce. Each namespace member is the identical function reference as its flat counterpart (push.setDeviceToken === setDeviceToken), just re-exposed under a shorter, grouped name ā pick whichever style reads better in your codebase, or mix them.
Usage
Import the namespace(s) you need directly:
import { push, user, inApp } from "reteno-react-native-sdk";
await user.setAttributes({ externalUserId: "USER_ID", user: { /* ... */ } });
const clickListener = push.setOnClickedListener((event) => {
// ...
});
inApp.setAutoOpenLinks(false);Or import everything under one alias if you prefer a single Reteno. prefix everywhere:
import * as Reteno from "reteno-react-native-sdk";
await Reteno.initialize({ apiKey: "YOUR_SDK_ACCESS_KEY" });
await Reteno.user.setAttributes({ externalUserId: "USER_ID", user: {} });
Reteno.events.addEventListener("pushReceived", (event) => {
// ...
});Note that a handful of top-level functions ā initialize, logEvent, logScreenView, forcePushData ā are not part of any namespace and stay flat-only; they don't belong to one specific feature area.
Namespace reference
user
user| Namespaced | Flat equivalent |
|---|---|
user.setAttributes | setUserAttributes |
user.setMultiAccountAttributes | setMultiAccountUserAttributes |
user.setAnonymousAttributes | setAnonymousUserAttributes |
See Tracking user information.
push
push| Namespaced | Flat equivalent |
|---|---|
push.setDeviceToken | setDeviceToken |
push.registerForRemoteNotifications | registerForRemoteNotifications |
push.getInitialNotification | getInitialNotification |
push.setOnReceivedListener | setOnRetenoPushReceivedListener |
push.setOnClickedListener | setOnRetenoPushClickedListener |
push.setOnButtonClickedListener | setOnRetenoPushButtonClickedListener (iOS only) |
push.setOnDismissedListener | setOnRetenoPushDismissedListener (Android only) |
push.setOnCustomDataListener | setOnRetenoCustomPushDataListener (Android only) |
push.requestNotificationPermission | requestNotificationPermission (Android only) |
push.getNotificationPermissionStatus | getNotificationPermissionStatus (Android only) |
push.updatePermissionStatusAndroid | updatePushPermissionStatusAndroid (Android only) |
push.pauseTriggeredInAppMessages | pausePushInAppMessages (Android only) |
push.setTriggeredInAppMessagesPauseBehaviour | setPushInAppMessagesPauseBehaviour (Android only) |
push.setGroupingRule | setNotificationGroupingRule (Android only) |
See Push notification.
events
events| Namespaced | Flat equivalent |
|---|---|
events.addEventListener | addEventListener |
events.removeEventListener | removeEventListener |
events.initializeEventHandler | initializeEventHandler |
inApp
inApp| Namespaced | Flat equivalent |
|---|---|
inApp.setLifecycleCallback | setInAppLifecycleCallback |
inApp.removeLifecycleCallback | removeInAppLifecycleCallback (Android only) |
inApp.beforeDisplay | beforeInAppDisplayHandler |
inApp.onDisplay | onInAppDisplayHandler |
inApp.beforeClose | beforeInAppCloseHandler |
inApp.afterClose | afterInAppCloseHandler |
inApp.onError | onInAppErrorHandler |
inApp.onCustomData | addInAppMessageCustomDataHandler |
inApp.pauseMessages | pauseInAppMessages |
inApp.setPauseBehaviour | setInAppMessagesPauseBehaviour |
inApp.setAutoOpenLinks | setAutoOpenLinks |
inApp.getAutoOpenLinks | getAutoOpenLinks |
See In-App Messages.
Note:
push.pauseTriggeredInAppMessages/push.setTriggeredInAppMessagesPauseBehaviour(Android-only, push-triggered in-apps) andinApp.pauseMessages/inApp.setPauseBehaviour(all in-apps, both platforms) wrap two different underlying methods ā they are not aliases of each other.
inbox
inbox| Namespaced | Flat equivalent |
|---|---|
inbox.getMessages | getAppInboxMessages |
inbox.markAsOpened | markAsOpened |
inbox.markAllAsOpened | markAllAsOpened |
inbox.getMessagesCount | getAppInboxMessagesCount |
inbox.subscribeUnreadCount | onUnreadMessagesCountChanged |
inbox.unsubscribeUnreadCount | unsubscribeMessagesCountChanged |
inbox.unsubscribeAllUnreadCount | unsubscribeAllMessagesCountChanged |
inbox.onUnreadCountChanged | unreadMessagesCountHandler |
inbox.onUnreadCountError | unreadMessagesCountErrorHandler (Android only) |
See App Inbox.
recommendations
recommendations| Namespaced | Flat equivalent |
|---|---|
recommendations.get | getRecommendations |
recommendations.logEvent | logRecommendationEvent |
See Recommendations.
ecommerce
ecommerce| Namespaced | Flat equivalent |
|---|---|
ecommerce.productViewed | logEcomEventProductViewed |
ecommerce.productCategoryViewed | logEcomEventProductCategoryViewed |
ecommerce.productAddedToWishlist | logEcomEventProductAddedToWishlist |
ecommerce.cartUpdated | logEcomEventCartUpdated |
ecommerce.orderCreated | logEcomEventOrderCreated |
ecommerce.orderUpdated | logEcomEventOrderUpdated |
ecommerce.orderDelivered | logEcomEventOrderDelivered |
ecommerce.orderCancelled | logEcomEventOrderCancelled |
ecommerce.searchRequest | logEcomEventSearchRequest |
See Ecommerce.
Migrating existing code
There is nothing to migrate ā this is purely additive, and flat imports keep working exactly as before. If you do want to move a file over to the namespaced style, it's a mechanical rename with no behavior change, since each namespace member is a direct reference to its flat function:
- import { setUserAttributes, setOnRetenoPushReceivedListener } from "reteno-react-native-sdk";
+ import { user, push } from "reteno-react-native-sdk";
- setUserAttributes({ externalUserId, user: payload });
+ user.setAttributes({ externalUserId, user: payload });
- setOnRetenoPushReceivedListener(onReceived);
+ push.setOnReceivedListener(onReceived);Types are unaffected either way ā SetUserAttributesPayload, RetenoSubscription, and the rest of the exported types are shared by both call styles.