I followed all the steps in order to set up the background fetch
but I'm suspecting that I made a mistake when writing the function performFetchWithCompletionHandler
in the AppDelegate.
Here is the warning that I get as soon as I simulate a background fetch
Warning: Application delegate received call to - application:
performFetchWithCompletionHandler:but the completion handler was never called.
Here's my code :
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")
}
}
}
}
How can I test if the background-fetch
is working ?