0

I have the task of finding out how to prevent newer android devices from killing the app which then will no longer be able to send local push notifications.. is there a way to do it ? I've heard of GMS.. any good ?

Scenario: User has a meeting in 21 days and one day before it he wants to get a notification. This should be stored locally, no server thing I guess. ?

Thanks

Update: Best Link: https://en.proft.me/2017/05/7/scheduling-operations-alarmmanager-android/

  • 1
    hi , follow this link , hope it's will help https://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ – Imran khan Feb 12 '19 at 10:42
  • It seems like you are talking about system `Notification` rather than push because you say it must be local. The "push" part of "push notification" means it is being sent from the server. – Richard Le Mesurier Feb 13 '19 at 08:53
  • 1
    Does this answer your question? [Push Notifications after App is killed](https://stackoverflow.com/questions/42477483/push-notifications-after-app-is-killed) – 钟智强 Jan 13 '22 at 15:09

1 Answers1

1

For push notifications you should use FCM (Firebase Cloud Messaging), GCM is deprecated and passed away.

FCM allows you to handle a messages, even if app is killed.

There are two types of messages in FCM, notification and data messages. Data messages are always processed by your app, notification can be handled automatically, if app is killed.

But you should use WorkManager or JobScheduler or something similar to schedule your job, because FirebaseMessagingService will be killed soon after receiving message.

Ufkoku
  • 2,384
  • 20
  • 44
  • even locally ? Just store them on device no server-thing. For example set a timer like in 3 weeks device has to fire an notification and store that event locally, will it do that after long time app was closed – GambitPlayer_3 Feb 12 '19 at 11:44
  • @GambitPlayer_3 For scheduling local events you can use [`AlarmManager`](https://www.google.com/search?q=alarmmanager&oq=AlarmMaang&aqs=chrome.1.69i57j0l5.2527j0j7&sourceid=chrome&ie=UTF-8]) – Ufkoku Feb 12 '19 at 12:16
  • Thank you ! But note that there is an issue with API 19+ concerning the OS restricting a bit.. – GambitPlayer_3 Feb 12 '19 at 12:33