0

I have the following code to send a birthday reminder:

await Notifications.scheduleNotificationAsync({
      content: {
        title: "Its NAME's birthday today!",
        body: "Don't forget to wish a happy birthday",
        sound: true,
        vibrate: [0, 500], // This also doesn't vibrate. If you have a solution to this too please let me know.
        color: "#eeeeee",
        priority: "MAX",
        subtitle: "Birthday Reminder",
      },
      trigger: {
        seconds: SECONDS_TO_THE_BIRTHDATE,
        channelId: "BirthdayReminder",
      },
    });

Say the birthdate is in march 1st then I would want to send a notification on the upcomming march 1st and then every year on march 1st at a specific time say 6am. How do I do it?

repeats:true

setting repeats to true repeated the notification but at "SECONDS_TO_THE_BIRTHDATE" interval, I want it to repeat at a interval of 1 year starting form that "SECONDS_TO_THE_BIRTHDATE".

I did find "YearlyTriggerInput" on the documentation but I have no idea how to use it.

Bimal Pandey
  • 93
  • 2
  • 8

1 Answers1

0

Apprantly I was supposed to use YearlyTriggerInput interface like:

await Notifications.scheduleNotificationAsync({
      content: {
        title: "Its NAME's birthday today!",
        body: "Don't forget to wish a happy birthday",
        sound: true,
        vibrate: [0, 500], // This also doesn't vibrate. If you have a solution to this too please let me know.
        color: "#eeeeee",
        priority: "MAX",
        subtitle: "Birthday Reminder",
      },
      trigger: {
        month: month,//set to the month (use js Date's month index)
        day: day, //The day of the month to notify
        hour: hour,
        minute: minute,
        channelId: "BirthdayReminder",
        repeats: true,
      },
    });

Note: I did test this by changing the date on my android and it does notify at the same time every year but I don't have a IOS device to test with me so I don't know about IOS.

Bimal Pandey
  • 93
  • 2
  • 8