vonovak / react-native-add-calendar-event

Create, view or edit events in react native using the standard iOS / Android dialogs
MIT License
350 stars 102 forks source link

This library should handle or at least document needed permissions #187

Open antoinerousseau opened 7 months ago

antoinerousseau commented 7 months ago

First of all, thanks for this great lib! 💚

I discovered the hard way that:

The solutions would be to:

kbqdev commented 6 months ago

Can you make a demo, i'm trying solve it. My app crash on both after event create.

UmeHabiab commented 4 months ago

i have fixed this by asking permission for android is like below

const writeStatus = await check(PERMISSIONS.ANDROID.WRITE_CALENDAR);
    const readStatus = await check(PERMISSIONS.ANDROID.READ_CALENDAR);

    if (writeStatus === RESULTS.BLOCKED || readStatus === RESULTS.BLOCKED) {
      return RESULTS.BLOCKED;
    }

    const writeResult = await request(PERMISSIONS.ANDROID.WRITE_CALENDAR);
    const readResult = await request(PERMISSIONS.ANDROID.READ_CALENDAR);

    if (writeResult === RESULTS.BLOCKED || readResult === RESULTS.BLOCKED) {
      return RESULTS.BLOCKED;
    }

    if (writeResult === RESULTS.GRANTED && readResult === RESULTS.GRANTED) {
      return RESULTS.GRANTED;
    } else if (
      writeResult === RESULTS.DENIED ||
      readResult === RESULTS.DENIED
    ) {
      return RESULTS.DENIED;
    }