5

I'm developing an android app using firebase, this app should push notifications twice a day by hours user should set in app settings.

I saw a similar question was asked at least 2 years ago, but no answer, maybe now there is an option to do it.

Is there anyway I can achieve this using Firebase ? If no, how can I achieve it ?

albert
  • 8,285
  • 3
  • 19
  • 32
AndroidDev
  • 101
  • 1
  • 1
  • 9
  • Possible duplicate of [FCM Schedule delivery date or time of push notification](https://stackoverflow.com/questions/39640469/fcm-schedule-delivery-date-or-time-of-push-notification) – AL. Mar 31 '18 at 18:30

1 Answers1

7

You can schedule sending notifications from the Firebase console. But that is limited to notifications you manually enter. There is no way to schedule "twice a day" delivery, nor is there an API to schedule the delivery programmatically.

This means that you'll have to write code to implement this yourself. One way to do this would be to use the Firebase Cloud Messaging API to send the messages, use the Firebase Realtime Database (or Cloud Firestore) to store information on when and where to send the messages, and then invoke a Cloud Function on a schedule to read the information from the database and call the FCM API.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks Frank, I did not manage to achieve what I wanted from firebase so I have done it with NotificationManager and AlarmManager, Thanks a lot – AndroidDev Apr 04 '18 at 10:43
  • Hi @androidDev, I am trying to do exactly what you want to do in my app. Are you willing to help me solve this issue by sending me some of your code snippets? – Think_Twice Jan 10 '20 at 16:45
  • If the app is removed from recent apps list, alarm manager will not work. This is because of the optimizations by many mobile phone manufacturers. So this is not a reliable technique to notify the user at exact time when the app is not alive. Push notification is one way to send message to the user, even when the app is not alive. Other way is through google Calendar API. It would have been helpful if FCM push notification API itself provides the scheduler for sending messages. – K Pradeep Kumar Reddy Apr 10 '20 at 12:12