我按照所有步骤进行了设置,background fetch
但我怀疑我performFetchWithCompletionHandler
在 AppDelegate 中编写函数时犯了一个错误。
这是我模拟后立即收到的警告background fetch
Warning: Application delegate received call to - application:
performFetchWithCompletionHandler:but the completion handler was never called.
这是我的代码:
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
if let tabBarController = window?.rootViewController as? UITabBarController,
viewControllers = tabBarController.viewControllers as [UIViewController]! {
for viewController in viewControllers {
if let notificationViewController = viewController as? NotificationsViewController {
firstViewController.reloadData()
completionHandler(.NewData)
print("background fetch done")
}
}
}
}
如何测试是否background-fetch
正常工作?