Search code examples
androidpush-notificationuser-inactivity

Android: How to send a push notification after a certain time of inactivity?


I want to send a push notification from my app if it was inactive (not used on this device) for a certain time of inactivity (for example one week).

I know how to send push notifications but I do not know how to add the time variable.

Hope you have some ideas!


Solution

  • I see two possible solutions:
    1. Setup an alarm using AlarmManager every time the user exits your application and cancel it whenever your application starts.
    2. In case your application sends http requests to a server, or a server gets notified, in any way, when the user uses your app, detect the inactivity in the server side and send a cloud message when the app has been inactive for x amount of time.