Schedule notification everyday for Flutter

Viewed 4404

I have a prayer-timing App with notifications to be shown for 5 prayers everyday.

For simplicity let's assume there are 5 events(prayers) everyday.

  1. 5:00
  2. 6:00
  3. 7:00
  4. 8:00
  5. 9:00

I want to schedule a notification for every event.

Till here, there is no problem, i can use the Flutter_local_notifications package and use the "daily" method to schedule these 5 notifications daily.

The problem is that these timings change every 2-3 days, so the timings of the notifications also have to be changed in that period.

For now i have written the code in such a way that, whenever the user opens the app, the notifications are scheduled again. This works, but the app freezes for a few seconds on start-up which looks really bad.

Is there any other way to do it?

EDIT : The prayer timings for the whole of next year are calculated in the app, the only problem is to schedule them.

1 Answers

As far as I understand your question, I would like to answer it.
Though your prayer timings change, if it has any specific pattern, you could also use Weekly Notification and set each day of the Week with different timings. Something like this:

await flutterLocalNotificationsPlugin.showWeeklyAtDayAndTime(
    0,
    'On Monday Morning',
    'Your Prayer at Monday',
    Day.Monday,
    time,
    platformChannelSpecifics);

Or else, you can send notifications online by Firebase Cloud Messaging (FCM) and there you can schedule it in the console and it will be reflected for all.
FCM Reference: https://firebase.google.com/products/cloud-messaging
For Flutter: https://pub.dev/packages/firebase_messaging
Hope that helps!
#Happy Coding!

Related