I am implementing BackgroundTasks Framework for updating the data. But I got the below issue
Could not schedule refreshApp: Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)"
Could not schedule data featch: Error Domain=BGTaskSchedulerErrorDomain Code=1 "(null)"
2019-10-01 19:19:32.550320+0530 SOBackgroundTask[34131:1129470] Can't end BackgroundTask: no background task exists with identifier 3 (0x3), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Use the BackgroundTasks framework to keep your app content up to date and run tasks requiring minutes to complete while your app is in the background. Longer tasks can optionally require a powered device and network connectivity. Register launch handlers for tasks when the app launches and schedule them as required.
A class for scheduling task requests that launch your app in the background.
The answer is simply 600 seconds (10 minutes), reason is provided by the article above.
The solution is to run on a device. I was running on a simulator. However, It was showing the Background App Refresh has been enabled in Settings while running on the simulator.
There may be some other reasons. Please visit https://developer.apple.com/documentation/backgroundtasks/bgtaskschedulererrorcode/bgtaskschedulererrorcodeunavailable?language=objc
Here are possible error codes for Domain=BGTaskSchedulerErrorDomain
extracted from ObjC headers with some explanation.
BGTaskSchedulerErrorCodeUnavailable = 1
// Background task scheduling functionality is not available for this app/extension. Background App Refresh may have been disabled in Settings.
BGTaskSchedulerErrorCodeTooManyPendingTaskRequests = 2
// The task request could not be submitted because there are too many pending task requests of this type. Cancel some existing task requests before trying again.
BGTaskSchedulerErrorCodeNotPermitted = 3
// The task request could not be submitted because the appropriate background mode is not included in the UIBackgroundModes array, or its identifier was not present in the BGTaskSchedulerPermittedIdentifiers array in the app's Info.plist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With