Handling notifications on iOS 10+


#1

I am trying to run some code after a user has received a notification on an iOS 10+ device while the app is running in the foreground. According to JUCE Documentation this seems to not be possible anymore through the PushNotifications::Listener::handleNotification() method. Is there another way to capture this event?


#2

handleNotification() should still be called when a user reacts to the notification on iOS 10+ even if the app is in foreground. The difference between iOS9 and iOS10+ is that pre iOS10 you would get handleNotification() instantly if the app was in foreground, the user would not even see the notification. That behaviour was not the best, so Apple improved it in iOS10 so that even when the app is in foreground the notification can appear and you will still get the notification only after a user has really reacted to it. If you wanted to just know that the notification appeared, you would have to modify JUCE implementation of PushNotifications::Pimpl::willPresentNotificationWithCompletionHandler() but note this would not mean that the user has reacted to it.