I have requirement of pushing in app notification to user based on following logic.
- Type A notification will be shown after every 24 hours.
- Type B notification will be shown after every 7 days.
- Type C notification will be shown after every 15 days.
I have used PeriodicWorkRequest
work manager as follows, its working fine until device is restart.
Once device is restart my work is not getting trigger.
build.gradle ---
implementation 'android.arch.work:work-runtime:1.0.0-alpha04'
Java code
PeriodicWorkRequest showNotification =
new PeriodicWorkRequest.Builder(ShowNotificationWorkManager.class, interval,
TimeUnit.HOURS)
.addTag(notificationType)
.setInputData(myData)
.build();
getWorkManger().enqueue(showNotification);