Schedule an Expo notification and cancel it an hour later?

621 Views Asked by At

Building an (Android) app for myself through Expo and React Native. I want to send scheduled time-sensitive notifications to the user (me). If the user hasn't interacted with a notification after an hour, it's irrelevant, so I would like to cancel the notification without the user needing to dismiss it. I would like to schedule many of these auto-dismiss notifications.

  1. Doesn't look like there's a way to "schedule" a cancellation. Seems like I could use setTimeout and cancelScheduledNotificationAsync to cancel it after an hour. Is there a better way?
  2. Even if setTimeout and cancelScheduledNotificationAsync works for the first notification I've scheduled, it seems like I could run into trouble with the second or third. That's a lot of time to be waiting in setTimeout. I'm worried about everything getting messed up if the device runs out of battery or something. Better ideas?

Thank you for your help! :)

0

There are 0 best solutions below