iOS10 Background fetch

Viewed 14188

I have tried to implement background fetch, to hopefully can wake the app from time to time.

I have done these:

      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
        return true
      }

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    debugPrint("performFetchWithCompletionHandler")
    getData()
    completionHandler(UIBackgroundFetchResult.newData)
  }

  func getData(){
    debugPrint("getData")
  }

I have also enable background fetch capabilities already. That's all i have done. And then i run the app. the function never called even after an hour (the phone slept).

What other things i have to do to make the function get called?

2 Answers
Related