Push Notifications — React Native SDK
Push delivery and metrics run in native Android/iOS modules. JavaScript exposes the same API surface as Flutter.
Prerequisites
- Firebase (Android) and/or APNs (iOS) configured in your app
- User identified via
identify() - Mobile E2E guide steps 1–5
Step 1 — Register device token
await OpenCDPSDK.instance.registerDeviceToken({
fcmToken: 'YOUR_FCM_TOKEN',
apnToken: 'YOUR_APNs_TOKEN',
});
Step 2 — Set up push notifications
await OpenCDPSDK.setupPushNotifications();
This delegates to native OpenCDPPushSetup on each platform.
Step 3 — Handle delivery and opens
// Foreground delivery
await OpenCDPSDK.handleForegroundPushDelivery(data);
// Background delivery
await OpenCDPSDK.handleBackgroundPushDelivery(data);
// User tapped notification
await OpenCDPSDK.handlePushNotificationOpen(data);
// Action button tap (Android / iOS)
await OpenCDPSDK.handlePushActionClick(data, actionId);
Step 4 — Android rich notifications
await OpenCDPSDK.showActionableNotification(data);
Call when FCM data includes image_url or action buttons. See Rich push images for layout behavior by Android version.
Step 5 — Android cold start
await OpenCDPSDK.handlePendingNotificationLaunch();
Step 6 — Test from console
Use the same person ID from identify() in Test push notification → Test by User ID.
See Identity and devices.
Platform setup details
- Android: FCM service, manifest — see Android push guide
- iOS: APNs, AppDelegate token forwarding, NSE for rich images — see iOS push guide
Verify it worked
- Notification arrives on device
- Debug logs show delivery/open metric POSTs
- Rich image displays per platform layout rules