Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
antoinerousseau opened this issue Mar 21, 2024 · 2 comments
Open

Comments

@antoinerousseau
Copy link

antoinerousseau commented Mar 21, 2024

First of all, thanks for this great lib! 💚

I discovered the hard way that:

  • On Android, if only requesting WRITE_CALENDAR, it does open the add event activity, but it makes my app crash. I had to add READ_CALENDAR to fix it but it defeats the whole idea of not having to ask for READ permission since it does not really need it.
  • On iOS, CALENDARS_WRITE_ONLY is an iOS 17+ permission, and must be replaced by CALENDARS in lower versions. Also, Calendars is always required in setup_permissions even for iOS 17, otherwise it crashes after saving an event.

The solutions would be to:

  • Make sure the code is fail-safe when not able to READ
  • Integrate react-native-permissions or document how to do it with the right permissions to ask
@kbqdev
Copy link

kbqdev commented Apr 26, 2024

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

@UmeHabiab
Copy link

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;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants