Search code examples
react-nativealarm

Best ways to implement Alarms into React Native?


I need to add the alarm functionality into my react-native app. An alarm that you have to manually stop/snooze like these ones . For that I have been browsing to know which library should I implement. These were the ones I found.

  1. react-native-alarms: But only works for android...

  2. react-native-alarm -notification: Also only works for android... And It seems more complex because it is based on implementing local push notification to look similar to an alarm.

  3. react-native-alarm: The only one that works booth for IOS and Android, but the documentation is super poor, I couldn't figure out how to use it (I think this library doesn't work as you can check here).

No one of this solutions seems to be functional in iOS and Android, simultaneously.

There any other solution?

Thanks in advance, this is my first React-Native project, I'm kind of lost in this problem.


Solution

  • i was having the same issue earlier. I tried all kind of third party libraries but some major and minor issues are still and unable to get rid of those, then i decided to implement react-native-push-notifications

    import PushNotification from 'react-native-push-notification';
    
                PushNotification.localNotificationSchedule({
                   id: 1,
                  message: `Reminder Message`,
                  date: new Date(Date.now() + 60 * 1000),
                  repeatType: 'day',
                  // repeatTime: 
                  allowWhileIdle: false,
                  exact: true,
    })
    For more understanding please see the example given by officials of push-notifications https://github.com/zo0r/react-native-push-notification/tree/master/example