You can get deleted notifications and wake up. But it’s important to understand the current implementation and how this affects the behavior of the application. All items are subject to change under Apple. At the time of this writing, you need to know (the first 2 people are obviously grok):
- First of all, your application should include “Remote Notifications” as the required background mode.
- Your application must register for remote notifications, as described in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html
- You MUST know about which callback in your application (UIApplicationDelegate for Swift) is based on your current state of the application (foreground, background, paused, etc.).
- Foreground - will call
application:didReceiveRemoteNotification or more preferably application:didReceiveRemoteNotification:fetchCompletionHandler - Background / Suspended - will ONLY (potentially) call
application:didReceiveRemoteNotification:fetchCompletionHandler , and you better call that fetchCompletionHandler for 30 seconds or your application terminates. If you have not implemented the method using fetchCompletionHandler, then you can probably only get the icon / alert from System IF , which you put in the contents of the APN message. Otherwise, you will not see anything.
Now here's the catch. The current iOS profiles of your application, and THEN decides whether to really wake your application. If you spend a lot of time testing APN, this will ultimately lead to your application becoming a bad citizen and it will not awaken your application (unless you are connected to power, at least). It will just wait for your application to start (which you can encourage the user to do through the system icon / notification in your APN message) and then put this remote notification in makeOutions for make / willFinishLaunchingWithOptions under the key UIApplicationLaunchOptionsRemoteNotificationKey
Gnewc source share