react-nativenotifications

How to check current set local notification?


Our app allows a user to set a daily notification reminding them to use our app. We have a bug currently, so I'm wanting to see what current notifications are set.

I've read the docs and found PushNotification.getScheduledLocalNotifications(callback); but I'm struggling on how to implement it. Really, I just want to console log scheduled notifications.

Any help would be great!

For reference, this is how we are currently setting the notification

if (Platform.OS === 'ios') {
  // iOS
  PushNotificationIOS.scheduleLocalNotification({
    alertTitle: config.reminder.title,
    alertBody: config.reminder.text,
    fireDate: tomorrow,
    repeatInterval: 'day'
  });
} else if (Platform.OS === 'android') {
  PushNotification.scheduleLocalNotification({
    title: config.reminder.title,
    body: config.reminder.text,
    date: tomorrow
  });
}

Solution

  • It has a callback return so try it like this and you should get your array of Scheduled Local Notifications

    PushNotification.getScheduledLocalNotifications((data) => {
      console.log('ScheduledLocalNotifications: ', data);
    });