vonovak / react-native-add-calendar-event

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

iOS17 Calendar Permission Changes #180

Closed kohchihao closed 8 months ago

kohchihao commented 11 months ago

There are new changes to the iOS17 Calendar permission where 2 new permissions are introduced full access and write only.

This will cause the presentEventCreatingDialog to be broken on iOS17 because when checking the permission and requesting via requestAccessToEntityType will cause the app to throw an error. Specifically the requestAccessToEntityType is deprecated on iOS17 and 2 new methods are introduced.

Ref:

I think other libraries are facing the same issues as well https://github.com/wmcmahan/react-native-calendar-events/issues/440

leonardohenriquedev commented 11 months ago

A workaround that i made is request permissions by react-native-calendar-events like this:

import ReactNativeCalendarEvents from "react-native-calendar-events"; import { presentEventCreatingDialog } from "react-native-add-calendar-event";

    ReactNativeCalendarEvents.requestPermissions().then((response) => {
      if (response === "authorized")
        try {
          presentEventCreatingDialog({ title: "" })
            .then((eventInfo) => {
              console.log(JSON.stringify(eventInfo));
            })
            .catch((error) => {
              console.log(error);
            });
        } catch (error) {
          console.log("calendar error:", error);
        }
    });

But first you need to make this change in your RNCalendarEvents.m file from react-native-calendar-events https://github.com/agent8/react-native-calendar-events/commit/368206ca3228cea97d8dfb913107bb61012062a2

phatlaunchdeck commented 10 months ago

A workaround that i made is request permissions by react-native-calendar-events like this:

import ReactNativeCalendarEvents from "react-native-calendar-events"; import { presentEventCreatingDialog } from "react-native-add-calendar-event";

    ReactNativeCalendarEvents.requestPermissions().then((response) => {
      if (response === "authorized")
        try {
          presentEventCreatingDialog({ title: "" })
            .then((eventInfo) => {
              console.log(JSON.stringify(eventInfo));
            })
            .catch((error) => {
              console.log(error);
            });
        } catch (error) {
          console.log("calendar error:", error);
        }
    });

But first you need to make this change in your RNCalendarEvents.m file from react-native-calendar-events agent8/react-native-calendar-events@368206c

Would it be simpler by just calling Permissions.request() from react-native-permissions so that we don't have to modify react-native-calendar-events?

claudiozam commented 10 months ago

@phatlaunchdeck we also have problems in react-native-permissions https://github.com/zoontek/react-native-permissions/issues/804

remipou commented 9 months ago

I made it work this way: https://github.com/vonovak/react-native-add-calendar-event/compare/master...remipou:react-native-add-calendar-event:master Don't forget to add a NSCalendarsWriteOnlyAccessUsageDescription key in your info.plist (https://github.com/vonovak/react-native-add-calendar-event/pull/182)

tholmgren commented 9 months ago

I made it work this way: master...remipou:react-native-add-calendar-event:master Don't forget to add a NSCalendarsWriteOnlyAccessUsageDescription key in your info.plist (#182)

Thank you, Remipou. This worked great for me!

ChronoByteCosmonaut commented 9 months ago

NSCalendarsUsageDescription has been deprecated. If your app needs read and write access to a person’s calendar data, use NSCalendarsFullAccessUsageDescription instead. If your app needs to create events in a person’s default calendar, use NSCalendarsWriteOnlyAccessUsageDescription instead.

[https://developer.apple.com/documentation/bundleresources/information_property_list/nscalendarsusagedescription]

ChronoByteCosmonaut commented 9 months ago

I made it work this way: master...remipou:react-native-add-calendar-event:master Don't forget to add a NSCalendarsWriteOnlyAccessUsageDescription key in your info.plist (#182)

Thank you, Remipou. This worked great for me!

Is there any way to mergen this PR??

ChronoByteCosmonaut commented 8 months ago

Any updates? Can @remipou ‘s fix be merged? @vonovak ? Or how can I use it in the mean time? Thanks!

ChronoByteCosmonaut commented 8 months ago

Any updates on this PR??

vonovak commented 8 months ago

Thus library no longer deals with permissions. Please use rn-permissions or similar, as documented in the Readme.