At every app start I enqueue periodic work using ExistingPeriodicWorkPolicy.KEEP, so that no additional work is queued if there is already a schedule.
Let's assume that in a future app update, I change the constraints or periodicity of the work, but keep the original uniqueName
.
will this change be ignored because the PeriodicWorkRequest
uses the same uniqueWorkName
?
Or will this not be a problem because all work for an app is cancelled when the app is updated?
What's the best approach here?
When you update your app the scheduled work is maintained.
If you want to modify the workRequest
the only option is to cancel the previous request and register a new one.
I don't see this as a WorkManager specific problem as a new application version may require to do some action just once (onboarding a new feature, migrating some preferences, modifying some WorkManager work, etc). There are some useful answers using SharedPreferences in this question.
I would add this WorkRequest change in the section of your application that handles upgrades.