I have a function which is sending an HTTP request once in 60 sec, but when I lock phone it stops. So, is there a way to send HTTP requests when a phone is locked? I've tried to do it in
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
but it's not worked.
That code seems right to me... It should work as long as the code that you add it in the applicationDidEnterBackground
function of your AppDelegate. If the device is locked shouldn't matter from what I've seen. It's still able to perform tasks if the device is locked (ie. play audio)
Also make sure that if you are doing anything in the background that the app has the ability to make Background refreshes, if need be. You can add that in your Capabilities tab under the main project file in Xcode. I think that might be where your issue stems from.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.