Search code examples
c#uwpwin-universal-appbackground-task

UWP BackgroundTask on App update


I have a short question, if i update my App, which contains a BackgroundTask, do i need to unregister and re-register the task after the update? I have experienced that the BackgroundTask does not work anymore after an Update on some user's devices and the user had to disable and enable it again. I saw in the msdn documentation a "ServicingComplete" BackgroundTask, which should be launched after an App update, so is it the right way, to re-register my main BackgroundTask in there? Or what is the favorite way to make a simple BackgroundTask work to 100% after an App update?


Solution

  • The answer is yes. If your app has updated, you need to

    • Unregister your background task
    • Call BackgroundExecutionManager.RemoveAccess();
    • Call BackgroundExecutionManager.RequestAccessAsync();
    • Register your task again

    In my own app I stash the latest version number in the local settings so that I can detect this.