DidReceiveRemoteNotification: fetchCompletionHandler: but the completion handler was not called

I am trying to implement a sampling completion block with no luck. Whenever I submit an APN, xcode still complains that it is not implemented. Here is 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 get in the xcode console is

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

Not sure if I implement the correct syntax here

+5
source share
3 answers

Uninstall println or change it to NSLog, then try again. Most likely, the problem is caused by the fact that this method suits you in the background, and not in the main thread. println is much simpler than NSLog, which is thread safe and tempered for years and years.

+8
source

I had the same problem, but a completely different solution. My problem is that I imported Intercom so that people can communicate in the application and seem to intercept notifications, and didReceiveRemoteNotification never called in my AppDelegate .

Finally, I can stop hitting my head against the wall, hope this can save some time.

+1
source

I don’t know why, but replacing println with NSLog , I solved the problem.

0
source

Source: https://habr.com/ru/post/1214273/


All Articles