Notificare / notificare-sdk-ios

Notificare's iOS SDK
MIT License
6 stars 1 forks source link

didReceiveNotification not being called on my NotificarePushDelegate #4

Open zeusent opened 2 years ago

zeusent commented 2 years ago

I wanted to know when a remote notification is being received.

My app delegate implements the NotificarePushDelegate protocol and it seems to be fine since both notificare(_:didOpenNotification:) and notificare(_:didOpenAction:for:) are being called when the notification or an action are opened

But for some reason notificare(_:didReceiveNotification:) never fires. Based on this I expected it to fire whenever a notification arrives on my device.

hpinhal commented 2 years ago

Can you provide more information about how you're testing this? With a particular focus on the app state. We were unable to reproduce this with the sample app available in this repo.

zeusent commented 2 years ago

Hey @hpinhal. Sorry for my late reply.

The app was in foreground. The presentation options were set exactly like in your Sample app (so a banner was showing at the top of the screen but the app itself had no idea that a notification arrived unless the user tapped said banner). The inbox was also not reloading unless that banner was interacted with.

We did try to compile the Sample app to compare but it's not an "open -> run" thing 'cause it seems a lot of things are missing for that, so we didn't bother to much with it 🙃

As it stands I don't think that something special was done on our end. In the end we've set the SWIZZLING_ENABLED to false and manually forwarded the bellow calls from the AppDelegate to Notificare.shared.push():

application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
application(_:didFailToRegisterForRemoteNotificationsWithError:)
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

This seemed to be working.

hpinhal commented 2 years ago

Hi, @zeusent.

The Sample cannot be an "open -> run" thing due to the fact there are several custom aspects to it or any other app. One would have to adjust the following items:

Regarding the problem itself, good catch on the swizzling bit. That would explain that event not being handled. Can you explain your app setup? Dependency manager, UI framework, etc. The only scenario we've detected that swizzling isn't working is in a full SwiftUI app.