Prerequisites
Before setting up push notifications, make sure you have:- Firebase Cloud Messaging (FCM) configured for Android
- Apple Push Notification Service (APNs) configured for iOS
- Push notification certificates or authentication keys uploaded to Firebase Console
- A user identified via
tappd.identify()— push tokens are always associated with an identified user
Installation
Install the React Native Firebase messaging package and its peer dependency:Setup
1
Request permissions
On iOS you must explicitly request permission before you can receive
notifications. On Android, FCM handles permission automatically.
2
Get the push token
Retrieve the FCM token that identifies this device:
3
Register the token with Tappd
Pass the token and the platform string to
registerPushToken():Complete Setup Example
Here’s a fullApp component that wires up all three steps and handles token refresh in one place:
Check Subscription Status
After registering a token, you can verify the user’s subscription state:Handle Token Refresh
FCM occasionally rotates push tokens. Always listen for refresh events and re-register so your user’s token stays current:Handle Push Notifications
- Foreground
- Background
- Notification taps
Handle messages while the app is in the foreground using
onMessage():Platform-Specific Setup
- iOS
- Android
1. Enable the Push Notifications capability
In Xcode:- Open your project and select your app target.
- Go to Signing & Capabilities.
- Click + Capability.
- Add Push Notifications.
2. Configure APNs in Firebase Console
- Open Firebase Console → Project Settings → Cloud Messaging.
- Under the Apple app configuration section, upload your APNs Authentication Key (
.p8) or APNs Certificate (.p12).
Troubleshooting
Token not registering
Token not registering
If
registerPushToken() throws an error or the token doesn’t appear in the
Tappd dashboard:- Ensure
identify()was called first — the SDK requires a known user before it can associate a device token. - Check FCM/APNs configuration — on iOS, confirm the APNs key or certificate is uploaded to Firebase Console. On Android, confirm
google-services.jsonis inandroid/app/. - Verify network connectivity — token registration requires an active internet connection.
- Check your error logs — wrap
registerPushToken()in try-catch and log any caught errors.
Notifications not being received
Notifications not being received
If push notifications aren’t arriving on the device:
- Verify the token is registered — check the Tappd dashboard to confirm the device appears under the user’s profile.
- Check subscription status — call
tappd.checkPushSubscription()and inspect thestatusfield. - Verify FCM/APNs setup — use the Firebase Console’s test message tool to send a direct test notification to the token.
- Check device permissions — on iOS, go to Settings → Notifications and confirm notifications are allowed for your app.
Best Practices
- Identify users before registering tokens — push tokens are tied to users; always call
identify()first. - Always listen for token refresh — FCM can rotate tokens at any time. A stale token means missed notifications.
- Track opens on both cold and warm starts — handle both
getInitialNotification()andonNotificationOpenedApp()to get complete open-rate data. - Wrap everything in try-catch — token retrieval and registration can fail due to network issues or misconfigured credentials.
- Use
Platform.OS— always pass'ios'or'android'toregisterPushToken()so Tappd routes notifications through the correct provider.