Milan Tejani
Milan Tejani

Reputation: 372

I want to schedule notification on specific date should i use workmanager?

I am developing one app where I want to schedule notification on a specific date and time.

Specifically on a date when the app trial is over. I am giving a 4-day app trial to the user and when the trial is over.

ex: the user installs the app on 05-03-2020 then the app will give notification on date 08-03-2020

so should I use the work manager to schedule notification or any other option in android?

Upvotes: 1

Views: 1166

Answers (1)

Harikumar Alangode
Harikumar Alangode

Reputation: 561

WorkManager is intended for tasks that are deferrable - that is, not required to run immediately and required to run reliably even if the app exits or the device restarts. For example:

  • Sending logs or analytics to backend services
  • Periodically syncing application data with a server

Alarms (based on the AlarmManager class) give you a way to perform time-based operations outside the lifetime of your application. For example, you could use an alarm to initiate a long-running operation, such as starting a service once a day to download a weather forecast.

Alarms have these characteristics:

  • They let you fire Intents at set times and/or intervals.
  • They operate outside of your application, so you can use them to trigger events or actions even when your app is not running, and even if the device itself is asleep.

So for your requirement, you should be using an AlarmManager instead of WorkManager as you only need to deliver a notification.

Upvotes: 3

Related Questions