Skip to main content

Core Methods

createPntaClient()

Creates a PNTA client for your project. Parameters:
  • projectId: Your PNTA project ID (format: prj_XXXXXXXXX)
  • baseUrl (optional): API base URL. Default: https://app.pnta.io/api/v1
Returns: a client with identify(), setMetadata(), and onNotificationTap() Throws: if projectId is empty

identify()

Registers or updates the device for a push token. It also sends the device name, model, OS version, locale, time zone, preferred languages, bundle identifier, and app version and build, so you can target them in topic rules. Parameters:
  • token: The native APNs or FCM token from getDevicePushTokenAsync()

setMetadata()

Updates device metadata. Keys with null or undefined values are skipped. Parameters:
  • token: The device’s push token
  • metadata: Key-value pairs

onNotificationTap()

Tracks a notification open and calls callback with the notification payload on every tap, including the tap that launches the app. The SDK reads the payload from the correct place on each platform. Parameters: Returns: a subscription. Call subscription.remove() to stop listening, for example in a useEffect cleanup.

Errors

identify() and setMetadata() reject with an Error when the request fails. The message includes the status code and path, for example PNTA 404 /identification: .... If onNotificationTap() cannot record an open, it logs a warning and does not throw.

Notification Payload

Every PNTA notification includes these fields. onNotificationTap() gives them to your callback:
  • notification_id: The notification’s ID
  • token: The device’s push token
  • link_to: The link you set when sending, if any
The SDK doesn’t open links. Your onNotificationTap() callback gets link_to and decides what to do. With Expo Router, router.push(payload.link_to) handles both kinds of links:
  • Internal routes (without a scheme) → Navigate in your app
    • Examples: /profile, /settings, /orders/123
    • The route must exist in your app/ directory
  • External URLs (with a scheme) → Open in the system browser or app
Without Expo Router, use your navigation library for internal routes and Linking.openURL() from react-native for external URLs.