vonovak / react-native-add-calendar-event

Create, view or edit events in react native using the standard iOS / Android dialogs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS17 Calendar Permission Changes

kohchihao opened this issue · comments

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 wmcmahan/react-native-calendar-events#440

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

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?

@phatlaunchdeck we also have problems in react-native-permissions zoontek/react-native-permissions#804

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)

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!

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]

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??

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

Any updates on this PR??

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