我一直在尝试实现获取完成块,但是没有运气。每当我发送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简单得多,后者是线程安全的,并且经过了数年的强化。

10-05 20:34
查看更多