My application works great with push notifications if the application was in the background and / or if the application is in the foreground.
The problem is that the application is complete (which I force by double-clicking on the home button, find the application and swipe up the screen).
I am using ios 9 and swift 2.
In the application delegate, didFinishLaunchingWithOptions, I:
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) application.registerUserNotificationSettings(settings) application.registerForRemoteNotifications()
Then:
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { application.registerForRemoteNotifications() }
Following didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError.
Then I use a relatively new method:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {...}
According to the documentation and the link, as against the old version of didReceiveRemoteNotification , this method is called if the application was interrupted (how to resist the call to will / did finishLaunchingWithOptions).
However, if it was pressed (which was received - I see it on the screen) and I launch the application after it is completed, this method does not seem to be called the code that processes push (just send a notification so that it is matched by the corresponding ViewController) not called out.
What am I missing? Is there an extra check I need to do in the didFinishLaunchingWithOptions file? Somewhere else?