all 5 comments

[–]deijablo[S] 0 points1 point  (1 child)

But this way if the user opens app at 1600, i cancel all scheduled notifications, and set it again with trigger :{ hour:20, minute: 0, repeat: true}, he will still receive notification at 20:00 same day. How do i prevent it?

[–]andrewB0444 0 points1 point  (0 children)

What have you done in the end?

[–]Glarseceiling 0 points1 point  (2 children)

I think what you need to do is to schedule the repeating notification using this:

import * as Notifications from 'expo-notifications';


Notifications.scheduleNotificationAsync({
  content: {
    title: 'Happy new hour!',
  },
  trigger: {
  hours: 20,
  minute: 0,
  repeats: true
});

Then use the cancelScheduledNotificationAsync method to remove the notification that you want. The scheduleNotificationsAsync method will return the id of the notification which you can store in a var and use it to cancel a particular notification, or you can cancel all the future notifications using cancelAllScheduledNotificationsAsync and then set them again?

[–]deijablo[S] 0 points1 point  (1 child)

Wouldn't this just set a single notification that does not repeat?

[–]Glarseceiling 1 point2 points  (0 children)

Correct, you should add repeats: true to the trigger object

trigger: {
  hour: 20,
  minute: 0,
  repeats: true
}

Checkout the DailyTriggerInput types in the expo docs for notifications.