Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data loss issue with Push Notification Capture service #113

Open
nlash-livly opened this issue Oct 31, 2024 · 7 comments · May be fixed by #168
Open

Data loss issue with Push Notification Capture service #113

nlash-livly opened this issue Oct 31, 2024 · 7 comments · May be fixed by #168
Labels
bug Something isn't working

Comments

@nlash-livly
Copy link

iOS 17.6.1 / Xcode 16 / Embrace SDK version 6.5.1 (also tried 6.5.0, 6.4.2)

When using the Push Notification Capture service, some data in push notifications is stripped out, causing app routing logic to fail upon tapping a notification. UNUserNotificationCenterDelegate methods + application(_:didReceiveRemoteNotification:fetchCompletionHandler:) are not invoked in AppDelegate with the push notification capture service enabled. Push notifications function normally when the push notification capture service is disabled.

We use an old version of the Branch SDK 0.36.0 to intercept notifications. The Branch handler is invoked, but some data gets nil'd out.

Setup:

      let captureServices = CaptureServiceBuilder()
           .addDefaults()
           .add(.pushNotification(options: .init(captureData: true))) // also tried false
           .build()

        try Embrace
            .setup(
                options: .init(appId: Constants.embraceKey,
                               captureServices: captureServices,
                               crashReporter: EmbraceCrashReporter(),
                               logLevel: .debug))
            .start()
@eliabsisay
Copy link
Contributor

@nlash-livly - thanks for submitting the issue. A member of our team will take a look and get back to you shortly.

@NachoEmbrace
Copy link
Contributor

NachoEmbrace commented Nov 5, 2024

Hey @nlash-livly ! We're trying to reproduce this issue.

A few questions:

  • Which push notification methods are you implementing in your AppDelegate?
  • Are you using UNUserNotificationCenterDelegate at all in your code? (I've checked Branch SDK v0.36.0's code and they don't seem to use UNUserNotificationCenter).
  • Can you clarify on the behavior you are seeing? From what I understand the issue is that some methods are not being called but you also mention "data being nil'd out".

@ArielDemarco ArielDemarco added the bug Something isn't working label Nov 7, 2024
@ArielDemarco
Copy link
Collaborator

Hey @nlash-livly! We made some changes in version 6.5.2 that we believe might fix the issue mentioned. Could you test it to confirm? If it doesn't, could you respond to @NachoEmbrace 's previous post?

@nlash-livly
Copy link
Author

nlash-livly commented Nov 27, 2024

Hello @ArielDemarco and @NachoEmbrace! Apologies for the delay.
Version 6.5.2 does not fix our issue.

  • Push notification methods implemented in AppDelegate:

    • application(_ :didRegisterForRemoteNotificationsWithDeviceToken:)
    • application(_:didFailToRegisterForRemoteNotificationsWithError:)
    • application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
    • userNotificationCenter(_:willPresent:notification:withCompletionHandler:)
  • We are using UNUserNotificationCenterDelegate. We set the delegate in application willFinishLaunchingWithOptions.

  • Behavior: When tapping a push notification with the service enabled, the app opens but does not perform routing.

    • Upon further investigation, I was mistaken about the data being stripped out of our notification payload.

Our other app works fine with the notification capture service enabled. The difference between the two apps is that in the working app, we implement userNotificationCenter(_:didReceive response:withCompletionHandler:).
Implementing this method on our problem app allows routing to work when the capture service is enabled. I'll change the code for now, but the original code works with v5.x (with the old push notification capture plist setting enabled).

(edits: typos, formatting)

@NachoEmbrace
Copy link
Contributor

Thanks for the detailed explanation once again!
Will look into this ASAP.

@NachoEmbrace
Copy link
Contributor

Hey @nlash-livly !

A few more questions:

  • Are you initializing the Embrace SDK before or after setting the UNUserNotificationCenterDelegate? Is it the same in both cases?
  • What is the iOS target version of the apps?

@soundsmitten
Copy link

Hi @NachoEmbrace,

  • The Embrace SDK is initialized before setting UNUserNotificationCenterDelegate. Following initialization, we start a span and then set the delegate. It's the same in both apps.
  • We target iOS 14 in both apps.

@ArielDemarco ArielDemarco linked a pull request Jan 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants