ios - didReceiveRemoteNotification :fetchCompletionHandler: but the completion handler was never called

标签 ios iphone swift

我一直在尝试实现获取完成 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/

相关文章:

ios - 无法模糊 ios 中的输入

ios - 如何使用 Swift 在 Sprite Kit 中将标签设置为特定颜色?

javascript - JS 方向更改监听器不会在 iOS 上触发,但在 Android 上会触发

ios - 点击 swift 时 tableviewcell 打开 url

Swift 默认参数使用缓存值

ios - 如何为大型 UIScrollView(随 View 滚动)设置背景图案

objective-c - UILabel 自动换行/字符换行

iphone - 如何在 iPhone 中实现搜索栏?

ios - 按日期和字符对核心数据属性进行排序

Swift 在 convenience init 中解包可选的 init