thanks for the quick reply @adamjnav
I was wondering if you could help me? I’ve been struggling with notifications for about three months now.
I really appreciate expo and I really just appreciate all the hard work from the expo team and how it makes it so easy to publish to the App Store. I really love it! I have been able to publish my first mobile app Using expo and this is been one of my goals for the past seven years.
I’ve looked at other mobile application solutions but I think expo is the most robust and makes it easiest to publish to the App Store.
At any rate I know you were very busy but I was wondering if you could help me to figure out how to do a simple local notification based on the date.
I’ve been looking at the API here: https://docs.expo.io/versions/v38.0.0/sdk/notifications/#schedulenotificationasyncnotificationrequest-notificationrequestinput-promisestring
and I can get the notification appear when I click button (based on the sample code on this page). but I can’t figure out how to add this CalendarNotificationTrigger
to the trigger of the scheduleNotificationAsync
Also, after looking at typescript more I was able to get this to write to the console using something like this:
const NewCal = (makeCal: CalendarNotificationTrigger) => {
const month = new Date().getMonth();
const dayOfMonth = new Date().getDate();
if (month == makeCal.dateComponents.month) {
console.log("it is ok")
} else {
console.log('no it is not')
}
}
const trigger = {
type: 'calendar',
repeats: false,
dateComponents: {
hour: 5,
month: 7,
minute: 37,
}
}
NewCal(trigger);
Notifications.scheduleNotificationAsync({
content: {
title: "calendar trigger!",
body: 'Change sides!',
},
trigger,
});
based on the docs on the API page I should be able to add the variable trigger
to the scheduleNotificationAsync
method — as seen in this example in the same API docs (where trigger is inserted as the value of the trigger
variable):
import * as Notifications from 'expo-notifications';
const trigger = new Date(Date.now() + 60 * 60 * 1000);
trigger.setMinutes(0);
trigger.setSeconds(0);
Notifications.scheduleNotificationAsync({
content: {
title: 'Happy new hour!',
},
trigger,
});
But I get an error when I attempt to add my trigger
object as the value of the trigger
key in the scheduleNotificationAsync
method.
my goal is to create a local notification based on the current date.
Thank you,