1 Reply
      Latest reply on Oct 3, 2019 6:13 AM by eskimo
      ohelei Level 1 Level 1 (0 points)

        I am trying to schedule a background task using the BGTaskScheduler in the Notification Service extension but am receiving an error while trying to submit it:

        (NSError) $R4 = 0x0000000157906d30 domain: "BGTaskSchedulerErrorDomain" - code: 3


        Code for the task submission is pretty basic:

        override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
            self.contentHandler = contentHandler
            let request = BGAppRefreshTaskRequest(identifier: "task")
            do {
                try BGTaskScheduler.shared.submit(request)
            } catch {
                NSLog("Could not schedule task \(error)")


        Documentation states that scheduling a task from the extension is possible but no additional info is provided: https://developer.apple.com/documentation/backgroundtasks/bgtaskscheduler?language=objc

        Maybe I am missing something?

        • Re: BGTaskScheduler in Notifications Service extension
          eskimo Apple Staff Apple Staff (12,085 points)

          In the BGTaskSchedulerErrorDomain, code 3 is BGTaskSchedulerErrorCodeNotPermitted, which has an description of:

          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.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"