Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expo set notification to a specific datetime

In Expo docs there is this example to show a notification after 60 seconds.

import * as Notifications from 'expo-notifications';

Notifications.scheduleNotificationAsync({
  content: {
    title: "Time's up!",
    body: 'Change sides!',
  },
  trigger: {
    seconds: 60,
  },
});

But how can I show a notification in a specific date for example at 08/28/2022 08:30AM

like image 934
cocojambo Avatar asked Oct 14 '25 15:10

cocojambo


1 Answers

Just a quick example of how to use the date property as Dmitro_ specified in the comment. It's actually DateTriggerInput notification type and you can use it as follows:

let date = new Date();
//Add 10 seconds to the current date to test it.
date.setSeconds(date.getSeconds() + 10);

await Notifications.scheduleNotificationAsync({
  content: {...},
  trigger: { date: date},
});
like image 79
Jakub Piga Avatar answered Oct 17 '25 12:10

Jakub Piga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!