Skip to main content
The Tappd Mobile SDK exposes a small, focused surface of methods that cover every use case — from identifying users and tracking events to managing push tokens and displaying in-app messages. This page documents every method, its parameters, return types, and example usage.

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)
See the TypeScript Types section below for the full TappdConfig interface.

Core Methods

identify(attributes)

Identify or update a customer using one or more identifiers. When you call identify(), 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.
Identification methods:
Identifier behaviour: Lookup priority: When the SDK searches for an existing customer it tries external_idemailphonealias. How identification works:
1

Provide at least one identifier

Pass external_id, email, phone, or alias inside attributes.
2

Customer matching

The SDK finds an existing customer record or creates a new one.
3

Event association

All future track() calls are automatically associated with this user.
4

Session linking

All current and future sessions are linked to the identified user.
5

Anonymous data merge

Any events tracked before identify() are merged into the customer profile.

track(eventName, properties?)

Track a custom event with optional properties. After you call identify(), 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:
Event tracking examples:
Event lookup priority: userId / user_idexternal_id / externalIdemailphonealias.

trackScreen(screenName, properties?)

Track a screen view, equivalent to a page view in web analytics. Signature: tappd.trackScreen(screenName: string, properties?: EventProperties): Promise<void>
Use useFocusEffect from React Navigation instead of useEffect to ensure screen views fire every time a screen comes into focus, not just on mount.

setExternalId(externalId)

Set the external ID for the currently identified user. Signature: tappd.setExternalId(externalId: string): Promise<void>
Throws an error if no user has been identified yet. Always call identify() first.

setUserAttributes(attributes)

Update attributes for the currently identified user. Pass any fields from CustomerAttributes to overwrite existing values. Signature: tappd.setUserAttributes(attributes: CustomerAttributes): Promise<void>
Throws an error if no user has been identified yet.

setCustomAttributes(attributes)

Set free-form custom attributes on the currently identified user. Signature: tappd.setCustomAttributes(attributes: Record<string, any>): Promise<void>
Throws an error if no user has been identified yet.

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>
Throws an error if the user is not identified. Call identify() before registerPushToken().

checkPushSubscription()

Check the push notification subscription status for the current user. Signature: tappd.checkPushSubscription(): Promise<{ subscribed: boolean; status: string; deviceCount: number }>
boolean
Whether the user has an active push subscription.
string
One of 'subscribed', 'opted_in', or 'unsubscribed'.
number
Number of registered devices for this user.
Throws an error if the user is not identified.

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 full InAppMessage 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>

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 a displayId 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.
At least one identifier (external_id, email, phone, or alias) is required. Store custom attributes either in the attributes object or as top-level properties.

Error Handling

All async SDK methods return promises and can throw. Wrap every call in a try-catch block to handle failures gracefully without crashing your app.
Common errors: