Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called

Tags:

ios

swift

iphone

I've been trying to implement the fetch completion block with no luck. Whenever I send an APN, xcode still complains that it's not implemented. Here's my code

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {

    println("2. User Data", userInfo)

    completionHandler(UIBackgroundFetchResult.NewData)

}

and the warning I am getting in the xcode console is this

Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

Not sure if I am implementing the right syntax here

like image 692
Mickey Mouse Avatar asked Feb 26 '15 22:02

Mickey Mouse


2 Answers

Remove the println or change it to a NSLog, then try again. Most likely the problem is caused because this method is coming to you in the background and not on the main thread. println is much simpler than NSLog, which is thread-safe and been hardened for years and years.

like image 86
David H Avatar answered Sep 20 '22 23:09

David H


I had an exact same issue but a totally different solution. The problem of mine is I imported Intercom so people can chat in-app, and seems like it intercepts the notifications and the didReceiveRemoteNotification never got called in my AppDelegate.

I can finally stop banging my head against the wall, hope this can save someone's time.

like image 23
LYu Avatar answered Sep 21 '22 23:09

LYu