sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Push Notifications instrumentation

Open philipphofmann opened this issue 2 years ago • 4 comments

Description

The SDK could subscribe to push notifications and add breadcrumbs without PII. Related to https://github.com/getsentry/sentry-java/issues/2728.

philipphofmann avatar May 24 '23 14:05 philipphofmann

Push notifications in iOS are handled through the UNUserNotificationCenter framework and its delegate methods. In order for the app detect a push notification the App delegate needs to implement UNUserNotificationCenter, the only way to detect this, is by swizzling it, there is no NSNotificationCenter notification related with push notification.

brustolin avatar Jun 14 '23 12:06 brustolin

We need to investigate getDeliveredNotifications:

brustolin avatar Jun 21 '23 12:06 brustolin

Using getDeliveredNotifications: does not looks like a good solution, because the most common path regarding notifications is to call removeAllDeliveredNotifications after the app open so the notifications don't hang forever in the notification center. The notification is also remove from notification center when the user tap on it.

brustolin avatar Jul 18 '23 14:07 brustolin

The solution to this will be using Swizzling. We need to have tests to make sure we're not preventing the app to get the notification. We need to have this as experimental feature for a while.

brustolin avatar Jul 19 '23 12:07 brustolin

also worth investigating is SDK behaviour in UNNotificationServiceExtension and whether we can add some logic there to instrument handling of PNs

kahest avatar Aug 18 '25 18:08 kahest