我一直在尝试实现获取完成 block ,但没有成功。每当我发送 APN 时,xcode 仍然提示它没有实现。这是我的代码
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
println("2. User Data", userInfo)
completionHandler(UIBackgroundFetchResult.NewData)
}
我在 xcode 控制台中收到的警告是这样的
Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.
不确定我在这里实现的语法是否正确
最佳答案
删除 println 或将其更改为 NSLog,然后重试。问题很可能是因为这个方法是在后台而不是在主线程上出现的。 println 比 NSLog 简单得多,NSLog 是线程安全的,并且经过多年强化。
关于ios - didReceiveRemoteNotification :fetchCompletionHandler: but the completion handler was never called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28753884/