iOS push notifications
Register iOS devices for push notifications with the PostHog iOS SDK, and capture when users open them. Before you start, connect a push channel.
Requirements
- iOS SDK 3.69.0 or later.
- iOS 14 or later for automatic registration and open capture. On iOS 13, SDK version 3 doesn't install these hooks, so you get no push events. SDK version 4 requires iOS 15.
- The Push Notifications capability turned on for your app. Your app asks for notification permission and calls
registerForRemoteNotifications(). config.enableSwizzlingset totrue, which is the default. Without swizzling, use manual registration.
Register the device
The SDK registers the device's APNs token and captures opens by default:
The SDK registers the APNs token under your bundle ID. If your app sends through Firebase instead, see iOS apps that send through Firebase.
iOS reports a notification tap only to UNUserNotificationCenter.current().delegate. If your app never sets one, the SDK can't capture any opens.
Set the delegate when your app launches:
With config.debug on, the SDK logs a warning if the delegate is still missing a few seconds after setup().
Register manually
If you turn off swizzling or manage the notification lifecycle yourself, set capturePushNotificationSubscriptions to false and register the token from application(_:didRegisterForRemoteNotificationsWithDeviceToken:):
To register an FCM token, pass your Firebase project ID as the app ID:
If you don't call reset() at sign-out, unregister the device yourself:
Capture opens
With automatic capture on, a tap on a remote notification captures $push_notification_opened. The SDK ignores notifications that your app schedules locally.
To capture an open yourself, call this from your notification delegate:
If you don't have a UNNotificationResponse, pass the fields instead:
From iOS SDK 3.75.0, both calls skip a notification that PostHog sent if the SDK captured it in the last 5 minutes. The field call has no notification ID, so it also skips a second send of the same workflow step in that time. To count each send, use capturePushNotificationOpened(response:).
Identity verification
If your channel uses identity verification, return a token from your backend through pushIdentityProvider. Call completion exactly once:
Troubleshooting
| Problem | What to check |
|---|---|
| The token never registers | Your app calls registerForRemoteNotifications(), and the user granted permission. If config.enableSwizzling is false, register manually. |
| Opens are never captured | Your app sets UNUserNotificationCenter.current().delegate, config.enableSwizzling is true, and the device runs iOS 14 or later. |
| A tap that launches the app isn't captured | If you start PostHog from JavaScript or Dart in your own cross-platform host, call PostHogSDK.prewarmPushNotificationOpenCapture() (iOS SDK 3.72.0 and later) from application(_:didFinishLaunchingWithOptions:). The PostHog React Native and Flutter SDKs do this for you. |
For problems that apply to every SDK, see push troubleshooting.





