react-native-add-calendar-event icon indicating copy to clipboard operation
react-native-add-calendar-event copied to clipboard

Possibility to add an alert for iOS

Open MayeuldP opened this issue 7 years ago • 9 comments

I added the possibility to set an alarm since there was none by default. It works for iOS, because in Android, it use the native calendar, and users already got reminder 5 or 10 minutes before any events on their calendar, but not on iOS if no alarm is set.

I just added a field alert, and manage the differences in ios/AddCalendarEvent.m and succeed to manage it thanks to EKAlarm.

You just have to pass a field alert in the eventConfig.

  • 0 will set an alarm equal to startDate.
  • 1 will set an alarm 5 minutes before startDate.
  • 2 will set an alarm 30 minutes before startDate.
  • 3 will set an alarm 60 minutes before startDate.

MayeuldP avatar Feb 15 '19 17:02 MayeuldP

Fell free to tell me if there's anything I forgot, or if you meet any troubles !

MayeuldP avatar Feb 15 '19 17:02 MayeuldP

Resolve conflicts and add functionality, please!

AndreyPatseiko avatar Jun 18 '20 03:06 AndreyPatseiko

yes please resolve the conflicts and merge !

arnaudambro avatar Jul 26 '20 14:07 arnaudambro

Just wanted to share what is working for me to add alerts to iOS. As suggested above I'm using alarmWithRelativeOffset. This allows me a way to pass in any alert in minutes to options.

    if (options[_alert]) {
        int offset = [RCTConvert int:options[_alert]];
        NSTimeInterval alarmOffset = offset*-60;
        EKAlarm * alarm = [EKAlarm alarmWithRelativeOffset:alarmOffset];
        event.alarms = @[alarm];
    }

jordanwade avatar Aug 12 '20 21:08 jordanwade

@jordanwade would you be willing to open a PR? it'd be much appreciated, thanks!

vonovak avatar Aug 12 '20 22:08 vonovak

Just wanted to share what is working for me to add alerts to iOS. As suggested above I'm using alarmWithRelativeOffset. This allows me a way to pass in any alert in minutes to options.

    if (options[_alert]) {
        int offset = [RCTConvert int:options[_alert]];
        NSTimeInterval alarmOffset = offset*-60;
        EKAlarm * alarm = [EKAlarm alarmWithRelativeOffset:alarmOffset];
        event.alarms = @[alarm];
    }

This works nicely on my testing as well, please open a PR :)

Also, would you mind implementing this to Android as well? Thanks!

phatlaunchdeck avatar Oct 23 '20 10:10 phatlaunchdeck

Ah would love this feature! but wouldn't know where to start with adding the Android functionality, @MayeuldP @vonovak any ideas if or when Android might be added and this might get merged?

Jbarget avatar Apr 22 '21 13:04 Jbarget

hello @Jbarget and thanks for commenting, as explained in the readme, I no longer actively develop the package. If you want to add new features, you can hire me, as explained https://github.com/vonovak/react-native-add-calendar-event#maintenance-notice

thank you

vonovak avatar Apr 22 '21 13:04 vonovak

Resolve conflicts and add functionality, please!

chococrypto avatar Oct 27 '22 09:10 chococrypto