De-register/Un-register a Background Task

I've been looking into the docs and the WWDC videos on how to register and execute background tasks on iOS. But is there a way to de-register/un-register our Background Task once we have completed our task successfully. Since I don't want the app to keep executing the same task if it has already been completed.

Which specific type of background task? One created with BGProcessingTaskRequest? Or BGAppRefreshTaskRequest?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I'm using BGAppRefreshTaskRequest to call an API once the user device has regained network connectivity. Only if the API call is completed successfully I don't want to schedule/trigger any more background tasks.

In that case I recommend that you cancel the task completely by calling the cancel(taskRequestWithIdentifier:) method.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Then the cancel(taskRequestWithIdentifier:) method needs to be called every time the OS tries to execute the background task which has already fulfilled its purpose, right?

De-register/Un-register a Background Task
 
 
Q