exponea / exponea-ios-sdk

MIT License
19 stars 27 forks source link

didReceiveRemoteNotification trigger in background only for silent notifications #34

Closed W3xly closed 2 years ago

W3xly commented 2 years ago

Hello! For the last few days, I've been trying to resolve an issue with notifications.

I found out that when I have the application turned off or in the background, after sending a notification from Exponea, alert will appear, but the didReceiveRemoteNotification method was not called. I also tryied to implement your PushNotificationManagerDelegate with pushNotificationOpened function, but it also gets called only when I open application through notification click. UNUserNotificationCenterDelegate with userNotificationCenter didRecieve method - same scenario..

But today I found out that my didReceiveRemoteNotification was triggered (with app in background), but only when I choose to send the notification as silent. (Silent push notification - Toggle)

Do you have any idea what the connection might be? Or what should I do to be able to process notification event if app is in background/dead.. According to Apple documentation, this should be possible. Thank you.

michaela-dev commented 2 years ago

Hi! Yes, the behaviour you are describing is correct. From docu:

If you need to call some code when notification is received (even when the app is in the background) you need to do it in your Notification Service Extension, didReceive method. Check this guide: https://github.com/exponea/exponea-ios-sdk/blob/develop/Documentation/Guide/PUSH_QUICKSTART.md#notification-service-extension Hope this helps!