> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # React Native push notifications Canonical URL: https://posthog.com/docs/workflows/push/react-native > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host). ## On this page - [Requirements](#requirements) - [Register the device](#register-the-device) - [Capture opens](#capture-opens) - [Identity verification](#identity-verification) - [Opt out](#opt-out) - [Troubleshooting](#troubleshooting) Register iOS and Android devices for [push notifications](https://posthog.com/docs/workflows/push.md) with the PostHog React Native SDK, and capture when users open them. Before you start, [connect a push channel](https://posthog.com/docs/workflows/push.md#connect-a-push-channel). ## Requirements - `posthog-react-native` 4.62.0 or later. - The [`@posthog/react-native-plugin`](https://www.npmjs.com/package/@posthog/react-native-plugin) package, 2.3.0 or later. Later sections give the versions that some features need. - Push set up in your app, for example with `@react-native-firebase/messaging`, and notification permission from the user. - iOS 14 or later for automatic registration and open capture on iOS. Push isn't supported on React Native Web or macOS. > **CocoaPods is becoming read-only.** [CocoaPods trunk becomes read-only on December 2, 2026](https://blog.cocoapods.org/CocoaPods-Specs-Repo/), and `posthog-ios` 4.0 and later is only published through Swift Package Manager (SPM). > > `@posthog/react-native-plugin` 3.0 and later always resolves `posthog-ios` through SPM, including on the CocoaPods path, so upgrading the plugin is enough. See [Upgrading to `@posthog/react-native-plugin` 3.0](https://posthog.com/docs/libraries/react-native.md#upgrading-to-posthogreact-native-plugin-30). > > Plugin 2.x stays on `posthog-ios` 3.x on every iOS dependency path, including the hybrid and full SPM setups, so switching paths doesn't bring newer iOS SDK versions. To get `posthog-ios` 4.0 and later, upgrade to plugin 3.0. > > This change doesn't affect `@posthog/react-native-plugin` releases on npm or Android. ## Register the device With the plugin installed, the SDK registers the device and captures opens by default: ```jsx ``` On iOS, the SDK registers the APNs token under your bundle ID when your app registers for remote notifications. On Android, it fetches the FCM token at startup and registers it under your Firebase project ID. **iOS needs a notification delegate** iOS reports a notification tap only to `UNUserNotificationCenter.current().delegate`. If nothing in your app sets one, the SDK can't capture any opens on iOS. The Android startup fetch doesn't see later token changes, so forward them: ```jsx import messaging from '@react-native-firebase/messaging' import { Platform } from 'react-native' if (Platform.OS === 'android') { messaging().onTokenRefresh((token) => posthog.registerPushNotificationToken(token)) } ``` ### Register manually If you manage tokens yourself, set `capturePushNotificationSubscriptions` to `false` and register the token: ```jsx await posthog.registerPushNotificationToken(token) ``` You can call it before the SDK finishes setup. The SDK queues the call. Without an `appId`, iOS registers an APNs token under your bundle ID, and Android registers an FCM token under your Firebase project ID. To register an FCM token on iOS, pass your Firebase project ID. See [iOS apps that send through Firebase](https://posthog.com/docs/workflows/push.md#ios-apps-that-send-through-firebase). ```jsx await posthog.registerPushNotificationToken(token, { appId: 'your-firebase-project-id' }) ``` If you don't call `posthog.reset()` at sign-out, unregister the device yourself: ```jsx await posthog.unregisterPushNotificationToken() ``` ## Capture opens The SDK captures every tap on a remote notification, whether it launches the app or arrives while the app runs. Some cases need a recent plugin version: - **iOS taps that launch the app** need `@posthog/react-native-plugin` 2.9.2 or later. The plugin installs its hook at launch, before your JavaScript runs. - **Android taps while the app runs** need `@posthog/react-native-plugin` 2.6.0 or later. Earlier versions capture only taps that launch the app. - **Android taps after the process is killed** need an `onNewIntent` override. See [below](#android-taps-after-the-process-is-killed). On Android, the SDK recognizes a tap by the `google.message_id` extra that Firebase puts on the intent, so it can't see push delivered outside FCM. It also can't see locally scheduled notifications, or notifications that your app draws from a foreground message. Capture those yourself: ```jsx posthog.capturePushNotificationOpened({ title: 'Your order shipped', body: 'Track it in the app', payload: { order_id: '1234' }, }) ``` Don't call it from `messaging().onNotificationOpenedApp` or `getInitialNotification()`, because the SDK already captures those taps. From `@posthog/react-native-plugin` 2.9.1, the manual call skips a notification that PostHog sent if the SDK captured it in the last 5 minutes. A handler that you add for other notifications still counts them twice. If you added an `onNotificationOpenedApp` handler for Android on an older plugin version, remove it when you upgrade. The native SDK builds and sends `$push_notification_opened`, so your JavaScript `before_send` never sees it. Remove sensitive content before you pass it to `capturePushNotificationOpened`. ### Android taps after the process is killed When Android kills your app's process but keeps its task in the recent apps list, React Native drops the tap's intent. No library in the app can see the tap, including PostHog, `@react-native-firebase/messaging`, and your deep links. An `onNewIntent` override in your `MainActivity` fixes all three. With the `posthog-react-native/expo` config plugin, `expo prebuild` adds the override for you, from `posthog-react-native` 4.74.0. To turn this off, set `patchMainActivityNewIntent` to `false`: ```json { "expo": { "plugins": [ ["posthog-react-native/expo", { "patchMainActivityNewIntent": false }] ] } } ``` In a bare React Native app, add the override to `MainActivity.kt` yourself. Call `setIntent(intent)` before `super`, or React Native drops the intent first: ```kotlin override fun onNewIntent(intent: Intent) { setIntent(intent) super.onNewIntent(intent) } ``` If your `MainActivity` already overrides `onNewIntent`, the config plugin doesn't change it and logs a warning. Add `setIntent(intent)` as the first line of your override. ## Identity verification If your channel uses [identity verification](https://posthog.com/docs/workflows/push.md#verify-device-identity), return a token from your backend through `pushIdentityProvider`: ```jsx { // Get a token for this user from your backend, then: return token // or null to send without one }, }} > ``` ## Opt out Set `capturePushNotificationSubscriptions` or `capturePushNotificationOpened` to `false` in the options. On iOS, the plugin installs its launch hook before your JavaScript runs, so `capturePushNotificationOpened: false` stops the event but not the hook. To skip the hook, set `com.posthog.posthog.CAPTURE_PUSH_NOTIFICATION_OPENED` to `false` in `Info.plist`, or in `ios.infoPlist` on Expo: ```json { "expo": { "ios": { "infoPlist": { "com.posthog.posthog.CAPTURE_PUSH_NOTIFICATION_OPENED": false } } } } ``` ## Troubleshooting | Problem | What to check | | --- | --- | | The token never registers | `@posthog/react-native-plugin` is installed. On Android, Firebase Messaging is on the classpath, which `@react-native-firebase/messaging` sets up. | | Opens aren't captured on iOS | Your app sets `UNUserNotificationCenter.current().delegate`, and the device runs iOS 14 or later. For taps that launch the app, use plugin 2.9.2 or later. | | Opens aren't captured on Android | The push goes through FCM. Use plugin 2.6.0 or later for taps while the app runs, and [override `onNewIntent`](#android-taps-after-the-process-is-killed) for taps after the process is killed. | For problems that apply to every SDK, see [push troubleshooting](https://posthog.com/docs/workflows/push.md#troubleshooting).