builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
259 stars 258 forks source link

Calendar permission not showing #507

Closed info-trone closed 8 months ago

info-trone commented 9 months ago

Describe the bug After adding all requirements for the package(info.plist, pod spec gcc settings, example code), im not getting a prompt nor am I seeing the setting in the app settings. This package has worked before IOS 17, I wonder if that could be the issue. I tried creating a new project only using this package and example code, but can't seem to get it to work.

To Reproduce Steps to reproduce the behavior:

  1. Start a new flutter project
  2. add single page with the example code, info.plist permissions, add the pod spec build settings
  3. startup the project and check if the calendars are being retrieved (print/debug)

Expected behavior Calendar permission to use the package. with the prompt necessary to give it

Device(s) tested

Flutter doctor image

Additional context I read through he ios17 notes and found this under privacy: "Improved sharing permissions give you even more control over what you share with apps, with an embedded photo picker and an add-only Calendar permission" could be applicable? im not sure

Also the permission_handler package won't give me a prompt for calendar permissions, but it will with other permissions

info-trone commented 9 months ago

Did some more searching, as seen in these issues from the permission_handler package. iOS 17 has indeed changed it's calendar permission and some additions will be needed to make this package work.

https://github.com/Baseflow/flutter-permission-handler/pull/1151 https://github.com/Baseflow/flutter-permission-handler/issues/1108

henry2man commented 9 months ago

Here it is some additional info that may be useful: https://developer.apple.com/documentation/technotes/tn3152-migrating-to-the-latest-calendar-access-levels https://developer.apple.com/documentation/eventkit/accessing_calendar_using_eventkit_and_eventkitui

henry2man commented 9 months ago

@info-trone It looks that "develop" code already contains the fix for iOS 17

Setup your deps as this:

  # TEMPORAL FIX for https://github.com/builttoroam/device_calendar/issues/507
  # device_calendar: ^4.3.1
  device_calendar:
    git:
      url: https://github.com/builttoroam/device_calendar.git
      ref: develop

I had to leave both keys in Info.plist, older NSCalendarsUsageDescription and newer NSCalendarsFullAccessUsageDescription in order to make it work with both iOS 16 and iOS 17:

    <key>NSCalendarsUsageDescription</key>
    <string>Usage explanation</string>
    <key>NSCalendarsFullAccessUsageDescription</key>
    <string>Usage explanation</string>
Quentinio commented 7 months ago

I tried changing the pod file as recommended with iOS 17 but still wasn't able to call the permissions dialog. My current work around was by invoking it from appdelegate.swift final String status = await platform.invokeMethod('checkCalendarAuthorizationStatus');