Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions contents/docs/workflows/push-notifications/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,17 @@ Registration and unregistration are durable. If the device is offline or the req

## Capturing opens

For the opens automatic capture misses (locally-scheduled notifications on either platform, plus warm-start taps and foreground messages on Android), call the manual API:
Taps on remote notifications are captured for you (see above). Automatic capture can't see locally-scheduled notifications, notifications you display yourself from a foreground message, or push delivered outside FCM on Android. Call the manual API only for those:

```react-native
import messaging from '@react-native-firebase/messaging'
import { Platform } from 'react-native'

if (Platform.OS === 'android') {
messaging().onNotificationOpenedApp((message) => {
posthog.capturePushNotificationOpened({
title: message.notification?.title,
body: message.notification?.body,
payload: message.data,
})
})
}
posthog.capturePushNotificationOpened({
title: 'Your order shipped',
body: 'Track it in the app',
payload: { order_id: '1234' },
})
```

Only call it for opens automatic capture can't see itself, or the tap is counted twice.
Don't wire this to `messaging().onNotificationOpenedApp` or `getInitialNotification()`. The SDK already captures those taps, and the manual call isn't deduplicated against them, so the open is counted twice. If you added an `onNotificationOpenedApp` handler for Android on an earlier plugin version, remove it when you upgrade to 2.6.0.

The `$push_notification_opened` event includes `$notification_title` and `$notification_body` (plus `$notification_subtitle` on iOS), and `$notification_action` for action-button taps. Notification content is only captured for notifications sent by PostHog. Opens of other notifications are still captured, but without title or body.

Expand Down
Loading