I'm having trouble using background fetch on swift 2.0 according to the tutorial -> https://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial3. I get this error: application:performFetchWithCompletionHandler: but the completion handler was never called.
Basically i have a function where i perform my actions (calling data on firebase) and i want it to execute on background.
Here is my app delegate code
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(
UIApplicationBackgroundFetchIntervalMinimum)
}
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 a1 = viewController as? HorariosViewController {
completionHandler(.NewData)
a1.interface()
}
}
}
}
here is how i get data from firebase on the interface function :
func interface() {
self.numeroDasOrações = []
self.adhan = []
if let snapshots = snapshot.children.allObjects as? [FDataSnapshot] {
for snap in snapshots {
if let postDictionary = snap.value as? Dictionary<String, AnyObject> {
let key = snap.key
let hSalat = Horarios(key: key, dictionary: postDictionary)
let hAdhan = Horarios(key: key, dictionary: postDictionary)
self.numeroDasOrações.append(hSalat)
self.adhan.append(hAdhan)
}
}
}
})
}
Xcode error :
Warning: Application delegate received call to -application:performFetchWithCompletionHandler: but the completion handler was never called.
Thanks in advance.