wmcmahan / react-native-calendar-events

📆 React Native Module for iOS and Android Calendar Events
MIT License
901 stars 289 forks source link

App crashes using save event on android #346

Open AndyCC25 opened 3 years ago

AndyCC25 commented 3 years ago

using the method saveEvent close the application, I have a notificationService wrapping the saveEvent method and passing a date with the format YYYY-mm-DD crashed the application

Environment

System: OS: macOS 10.15.7 CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz Memory: 442.09 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.3.0 - ~/.nvm/versions/node/v14.3.0/bin/node Yarn: 1.22.4 - ~/.nvm/versions/node/v14.3.0/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v14.3.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Not Found Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.2, 29.0.3 System Images: android-28 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: /undefined - /usr/bin/xcodebuild Languages: Java: 1.8.0_275 - /usr/bin/javac Python: 3.8.5 - /opt/anaconda3/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to Reproduce

const createEvent = async () => {
    var startDateUTC =  '2021-01-31T14:00:00.000Z';
    const event = {
      title: 'my first event',
      startDate: moment(startDateUTC).subtract(1, 'hours').toISOString(),
      endDate: moment(startDateUTC).toISOString(),
    };
    const calendar = calendars.pop();
    console.log(calendar);
    const result = await calendarService.addCalendarEvent(event, calendar);
  }
  return (
    <>
      <Appbar>
        <Appbar.Action
          icon="archive"
          onPress={() => console.log('Pressed archive')}
        />
        <Appbar.Action icon="mail" onPress={() => console.log('Pressed mail')} />
        <Appbar.Action icon="label" onPress={async () => await createEvent()} />
        <Appbar.Action
          icon="delete"
          onPress={() => notificationService.scheduleNotification({ title: "hello", message: "its me andy", date: new Date(Date.now() + 60 * 1000) })}
        />
      </Appbar>
      <ProcessPage />
    </>
  );

Expected Behavior

should save the event

Actual Behavior

the app crash and is forced to stop

MoOx commented 3 years ago

Can you try passing timestamp instead of ISOstring for dates?

AndyCC25 commented 3 years ago

I've tried using new Date(), but still the application is closed immediately or what kind of timestamp I should use?

predescu commented 3 years ago

I had the same issue but @MoOx comment helped me out. Thanks I'm using luxon and changing from DateTime.toISO() to DateTime.toMillis() worked.

jfurdock commented 2 years ago

Still crashing on Android on SaveEvent

const saveEvent = await RNCalendarEvents.saveEvent('Here is my event', { startDate: '2021-09-19T19:26:00.000Z', endDate: '2021-09-22T19:26:00.000Z', description: "Test Event!", }, { sync: true });

Tried .getTime() as well to convert to milliseconds and still closing the app, can't seem to even get errors to log. Any ideas? If I remove the sync property it will save the event, but can't seem to get Google Sync to fire without it crashing

mickaelxd commented 2 years ago

@jfurdock Any lucky? My app is closing when I save an event too. What have you did to fix this issue?

abhishekchotaliya commented 2 years ago

Facing the same issue. await RNCalendarEvents.checkPermissions(false) output is authorized However, app crashes while saving the event

await RNCalendarEvents.saveEvent('My Event', {
    calendarId: '3',
    notes: 'helloworld',
    attendees: ['email@yahoo.com']
})

Only output:

WARN  Possible Unhandled Promise Rejection (id: 0):
Error: Unable to save event
deflexable commented 2 years ago

facing this issue also, any work around or fix for this??

deflexable commented 2 years ago

removing the attendees property and making the id integer string stops the crashing for me

ragsav commented 1 year ago

I was facing the same issue, my mistake was, I was passing calenderId as number, try passing it as string

calendarId: 1 -> crash

calendarId: '1' -> works fine

ipoogleduck commented 1 year ago

I'm getting a crashing issue on android, but only for repeating events

OmarUsman777 commented 1 year ago

I'm getting a crashing issue on android, but only for repeating events

Any Luck?

rohitashPrajapati commented 7 months ago

Attendies email id seems required, so I would suggest filter the attendees whose email is not available and also keep the calendarId as string. This worked for me.

Duya3fithou commented 3 weeks ago

I was facing the same issue, my mistake was, I was passing calenderId as number, try passing it as string

calendarId: 1 -> crash

calendarId: '1' -> works fine

Holy F. It's really working. <3