Constructor
new TappdSDK(config)
Create a new SDK instance. You typically do this once — at your app root or inside a context provider — and share it throughout your application. Signature:new TappdSDK(config: TappdConfig)
TappdConfig interface.
Core Methods
identify(attributes)
Identify or update a customer using one or more identifiers. When you callidentify(), the SDK automatically merges any events or sessions that were tracked anonymously before identification. The SDK generates its own internal identifier; you never need to manage one yourself.
Signature: tappd.identify(attributes: CustomerAttributes): Promise<void>
TypeScript interface:
You must include at least one identifier —
external_id, email, phone, or alias — in the attributes object. The call will fail if none are provided.- External ID (Recommended)
- Email Only
- Phone Only
- Alias
- Multiple Identifiers
Use your internal database user ID as the primary identifier for best results.
| Identifier | Notes |
|---|---|
external_id | Your database user ID — used as the primary identifier. Generates an internal userId automatically. |
email | Auto-normalized (lowercased and trimmed). Can be the sole identifier. |
phone | Can be the sole identifier. |
alias | Useful for legacy or custom identification schemes. Custom alias types are stored as 'custom'. |
external_id → email → phone → alias.
How identification works:
track(eventName, properties?)
Track a custom event with optional properties. After you callidentify(), the SDK automatically associates every subsequent track() call with the identified user — you don’t need to repeat identifier fields. You can, however, pass identifiers explicitly in properties if you need to associate an event with a specific user without a prior identify() call.
Signature: tappd.track(eventName: string, properties?: EventProperties): Promise<void>
EventProperties interface:
- After identify (auto-associated)
- With external_id
- With email
- With phone
- With alias
userId / user_id → external_id / externalId → email → phone → alias.
trackScreen(screenName, properties?)
Track a screen view, equivalent to a page view in web analytics. Signature:tappd.trackScreen(screenName: string, properties?: EventProperties): Promise<void>
setExternalId(externalId)
Set the external ID for the currently identified user. Signature:tappd.setExternalId(externalId: string): Promise<void>
setUserAttributes(attributes)
Update attributes for the currently identified user. Pass any fields fromCustomerAttributes to overwrite existing values.
Signature: tappd.setUserAttributes(attributes: CustomerAttributes): Promise<void>
setCustomAttributes(attributes)
Set free-form custom attributes on the currently identified user. Signature:tappd.setCustomAttributes(attributes: Record<string, any>): Promise<void>
Push Notification Methods
registerPushToken(token, platform)
Register a Firebase Cloud Messaging (FCM) push token for the current user so they can receive push notifications. Signature:tappd.registerPushToken(token: string, platform: 'ios' | 'android'): Promise<void>
checkPushSubscription()
Check the push notification subscription status for the current user. Signature:tappd.checkPushSubscription(): Promise<{ subscribed: boolean; status: string; deviceCount: number }>
Whether the user has an active push subscription.
One of
'subscribed', 'opted_in', or 'unsubscribed'.Number of registered devices for this user.
trackPushOpen(remoteMessage)
Track a push notification tap event. Call this inside your notification-opened handler to record that the user opened the app from a push notification. Signature:tappd.trackPushOpen(remoteMessage: object): Promise<void>
Utility Methods
getSessionId()
Return the current session ID. Signature:tappd.getSessionId(): string | null
getAnonymousId()
Return the anonymous ID assigned before the user is identified. This value persists across app launches (via AsyncStorage) until the user is identified. Signature:tappd.getAnonymousId(): string
reset()
Clear all user data and start a new anonymous session. Call this on user logout so subsequent events are not attributed to the previous user. Signature:tappd.reset(): void
cleanup()
Flush final events, remove listeners, and cleanly shut down the SDK. Call this when your app moves to the background or closes. Signature:tappd.cleanup(): void
In-App Message Methods
setMessageRenderCallback(callback)
Register the function the SDK calls when it needs to render a message. This step is required in React Native — without it, messages are fetched but never displayed. Signature:tappd.setMessageRenderCallback(callback: (message: InAppMessage) => void): void
getInAppMessages()
Fetch all pending in-app messages for the current user. Signature:tappd.getInAppMessages(): Promise<InAppMessage[]>
displayInAppMessage(message)
Display a specific message by passing the fullInAppMessage object. This triggers the render callback you registered with setMessageRenderCallback().
Signature: tappd.displayInAppMessage(message: InAppMessage): Promise<void>
displayPendingMessages()
Fetch and display all messages that are ready to be shown in one call. Signature:tappd.displayPendingMessages(): Promise<void>
dismissMessage(messageId)
Dismiss a message and automatically track the dismissal event. Signature:tappd.dismissMessage(messageId: string): Promise<void>
trackMessageEvent(messageId, eventType, metadata?)
Track a custom interaction with an in-app message — for example, a button click inside the message. Signature:tappd.trackMessageEvent(messageId: string, eventType: string, metadata?: object): Promise<void>
Banner Methods
getBanners(selector, options?)
Fetch banners for a given placement selector. Signature:tappd.getBanners(selector: string, options?: { forceRefresh?: boolean }): Promise<Banner[]>
banners.display(bannerId, variantId, selector)
Display a banner variant in a named placement. Returns adisplayId you use for subsequent click and dismiss calls.
Signature: tappd.banners.display(bannerId: string, variantId: string, selector: string): Promise<string>
banners.click(bannerId, displayId)
Track a banner click event. Signature:tappd.banners.click(bannerId: string, displayId: string): Promise<void>
banners.dismiss(bannerId, displayId)
Track a banner dismissal event. Signature:tappd.banners.dismiss(bannerId: string, displayId: string): Promise<void>
TypeScript Types
Use these interfaces to keep your integration fully type-safe.TappdConfig
TappdConfig
CustomerAttributes
CustomerAttributes
external_id, email, phone, or alias) is required. Store custom attributes either in the attributes object or as top-level properties.EventProperties
EventProperties
InAppMessage
InAppMessage
Banner
Banner
Error Handling
All async SDK methods return promises and can throw. Wrap every call in atry-catch block to handle failures gracefully without crashing your app.
| Error message | Cause | Fix |
|---|---|---|
"App ID is required" | appId is missing or empty | Copy your App ID from the Tappd dashboard |
"User must be identified first" | Called a method that requires identification before identify() | Call identify() first |
"Request failed: ..." | Network or API error | Check your apiUrl and network connectivity |
"AsyncStorage error" | @react-native-async-storage/async-storage not installed | Install the package and run pod install |