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

XCode 15 cordova-ios@7.0.1 : Calendars list returns nothing #565

Open
hooliapps opened this issue Sep 20, 2023 · 8 comments
Open

XCode 15 cordova-ios@7.0.1 : Calendars list returns nothing #565

hooliapps opened this issue Sep 20, 2023 · 8 comments

Comments

@hooliapps
Copy link

hooliapps commented Sep 20, 2023

Hello, i installed the last XCode 15 on Ventura (ios min version 11) / iOS 17 / cordova-ios@7.0.1

Plugin don't crash but don't show any calendar.

I get the warning message "accept or not", but after list is empty.

Do you have any idea please ? (Worked since long time)

<plugin name="cordova-plugin-calendar" spec="5.1.6">
	<variable name="CALENDAR_USAGE_DESCRIPTION" value="Export hours to calendar" />
</plugin>

<edit-config target="NSCalendarsUsageDescription" file="*-Info.plist" mode="merge">
	<string>Synchronize planning with calendar</string>
</edit-config>

window.plugins.calendar.listCalendars(openCalendarsListSuccess, openCalendarsListError);
I get openCalendarsListSuccess response, but the calendars list is empty.

@kallewangstedt
Copy link

I have the same issue. When fetching all calendars by window.plugins.calendar.listCalendars() it returns an empty array. When using window.plugins.calendar.findEvent() it returns the error No default calendar found. Is access to the Calendar blocked for this app?

There is a default calendar set and the app has full access to the calendars.

@kallewangstedt
Copy link

Fix for this problem can be found in this PR: #566

@hooliapps
Copy link
Author

Thanks a lot i will test asap.

@hooliapps
Copy link
Author

I confirm that your solution + JS code work perfectly without changing anything in cordova.xml

I just need to changed my code to call your functions.

Tested on XCode 15 / iOS 17 / iPhone 13 Pro Max.

Not tested on any other version or XCode.

@hooliapps
Copy link
Author

Finally, i retested by deleting the App then reisntalling with Testflight but dont works anymore.

I think we need to add new Permissions in cordova.

image

@matfantinel
Copy link

For the record, the cause of this are likely the changes in iOS 17 highlighted here.

For those using Capacitor, you might need to add NSCalendarsFullAccessUsageDescription to Info.plist as well, although I haven't tried with the code in the PR yet.

@kallewangstedt
Copy link

The README states that for iOS10+ you need to provide a reason in the plist.

@sjregan
Copy link

sjregan commented Oct 3, 2023

I've created a new pull request to address some of the issues.

Thanks @kallewangstedt for your original pull request which mine is based on.

My pull request also allows write only access to be requested for the calendar. However, this does create a potential issue where requests might fail if the following is done in this order:

  1. Request full calendar access
  2. Request write only calendar access
  3. Execute read calendar request

I don't actually know how to write Objective C, so I would do a proper review and tests of my pull request.

I could solve the above issue if someone can explain the following to me:

Why is self.eventStore used in some places:
https://github.com/sjregan/Calendar-PhoneGap-Plugin/blob/2b309a9ea7769f69bb40cae9552673a83187a1d6/src/ios/Calendar.m#L331C60-L331C71

e.g.

datedEvents = [self.eventStore eventsMatchingPredicate:[eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendars]];

And not others?
https://github.com/sjregan/Calendar-PhoneGap-Plugin/blob/2b309a9ea7769f69bb40cae9552673a83187a1d6/src/ios/Calendar.m#L526

NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray];

Is this a bug, or a deliberate choice for some reason?

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

4 participants