iOS 13 Schedule iOS background tasks

For:

BGTaskSchedulerErrorDomain error 3

Check inside the project’s .xcodeproj file for the appropriate target. Then go to the info tab and Custom iOS Target Properties and check that the permitted background task scheduler identifiers (BGTaskSchedulerPermittedIdentifiers) are added.

This solved my problem when adding BackgroundTasks to an existing project.


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.