Namespaced API

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

NamespacedFlat equivalent
user.setAttributessetUserAttributes
user.setMultiAccountAttributessetMultiAccountUserAttributes
user.setAnonymousAttributessetAnonymousUserAttributes

See Tracking user information.

push

NamespacedFlat equivalent
push.setDeviceTokensetDeviceToken
push.registerForRemoteNotificationsregisterForRemoteNotifications
push.getInitialNotificationgetInitialNotification
push.setOnReceivedListenersetOnRetenoPushReceivedListener
push.setOnClickedListenersetOnRetenoPushClickedListener
push.setOnButtonClickedListenersetOnRetenoPushButtonClickedListener (iOS only)
push.setOnDismissedListenersetOnRetenoPushDismissedListener (Android only)
push.setOnCustomDataListenersetOnRetenoCustomPushDataListener (Android only)
push.requestNotificationPermissionrequestNotificationPermission (Android only)
push.getNotificationPermissionStatusgetNotificationPermissionStatus (Android only)
push.updatePermissionStatusAndroidupdatePushPermissionStatusAndroid (Android only)
push.pauseTriggeredInAppMessagespausePushInAppMessages (Android only)
push.setTriggeredInAppMessagesPauseBehavioursetPushInAppMessagesPauseBehaviour (Android only)
push.setGroupingRulesetNotificationGroupingRule (Android only)

See Push notification.

events

NamespacedFlat equivalent
events.addEventListeneraddEventListener
events.removeEventListenerremoveEventListener
events.initializeEventHandlerinitializeEventHandler

inApp

NamespacedFlat equivalent
inApp.setLifecycleCallbacksetInAppLifecycleCallback
inApp.removeLifecycleCallbackremoveInAppLifecycleCallback (Android only)
inApp.beforeDisplaybeforeInAppDisplayHandler
inApp.onDisplayonInAppDisplayHandler
inApp.beforeClosebeforeInAppCloseHandler
inApp.afterCloseafterInAppCloseHandler
inApp.onErroronInAppErrorHandler
inApp.onCustomDataaddInAppMessageCustomDataHandler
inApp.pauseMessagespauseInAppMessages
inApp.setPauseBehavioursetInAppMessagesPauseBehaviour
inApp.setAutoOpenLinkssetAutoOpenLinks
inApp.getAutoOpenLinksgetAutoOpenLinks

See In-App Messages.

Note: push.pauseTriggeredInAppMessages / push.setTriggeredInAppMessagesPauseBehaviour (Android-only, push-triggered in-apps) and inApp.pauseMessages / inApp.setPauseBehaviour (all in-apps, both platforms) wrap two different underlying methods — they are not aliases of each other.

inbox

NamespacedFlat equivalent
inbox.getMessagesgetAppInboxMessages
inbox.markAsOpenedmarkAsOpened
inbox.markAllAsOpenedmarkAllAsOpened
inbox.getMessagesCountgetAppInboxMessagesCount
inbox.subscribeUnreadCountonUnreadMessagesCountChanged
inbox.unsubscribeUnreadCountunsubscribeMessagesCountChanged
inbox.unsubscribeAllUnreadCountunsubscribeAllMessagesCountChanged
inbox.onUnreadCountChangedunreadMessagesCountHandler
inbox.onUnreadCountErrorunreadMessagesCountErrorHandler (Android only)

See App Inbox.

recommendations

NamespacedFlat equivalent
recommendations.getgetRecommendations
recommendations.logEventlogRecommendationEvent

See Recommendations.

ecommerce

NamespacedFlat equivalent
ecommerce.productViewedlogEcomEventProductViewed
ecommerce.productCategoryViewedlogEcomEventProductCategoryViewed
ecommerce.productAddedToWishlistlogEcomEventProductAddedToWishlist
ecommerce.cartUpdatedlogEcomEventCartUpdated
ecommerce.orderCreatedlogEcomEventOrderCreated
ecommerce.orderUpdatedlogEcomEventOrderUpdated
ecommerce.orderDeliveredlogEcomEventOrderDelivered
ecommerce.orderCancelledlogEcomEventOrderCancelled
ecommerce.searchRequestlogEcomEventSearchRequest

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.