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

iOS 17 PlatformException(500, That account does not allow calendars to be added or removed., null, null) #490

Open
Allenxuxu opened this issue Jun 30, 2023 · 27 comments
Labels
bug Something isn't working

Comments

@Allenxuxu
Copy link

Describe the bug
In iOS17 , it will print

PlatformException(500, That account does not allow calendars to be added or removed., null, null)

Flutter doctor
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.4.1 22F82 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

@Allenxuxu Allenxuxu added the bug Something isn't working label Jun 30, 2023
@IVLIVS-III
Copy link
Contributor

@Allenxuxu please add steps to reproduce your issue. What didi you do that caused this exception? What did you expect should have happened instead if everything worked correctly?

@IVLIVS-III IVLIVS-III added the more information required The issue requires more information before it can be actioned label Jun 30, 2023
@Allenxuxu
Copy link
Author

@Allenxuxu please add steps to reproduce your issue. What didi you do that caused this exception? What did you expect should have happened instead if everything worked correctly?

In iOS17, if you call createOrUpdateEvent , it can't work and print:

PlatformException(500, That account does not allow calendars to be added or removed., null, null)

In other version iOS, it works well.

@IVLIVS-III IVLIVS-III removed the more information required The issue requires more information before it can be actioned label Jun 30, 2023
@thomassth
Copy link
Contributor

is there some API or permission changes to ios17?

@IVLIVS-III
Copy link
Contributor

is there some API or permission changes to ios17?

not according to Apple's own documentation

Bildschirmfoto 2023-06-30 um 21 28 47 Bildschirmfoto 2023-06-30 um 21 31 03 Bildschirmfoto 2023-06-30 um 21 31 24

@Allenxuxu
Copy link
Author

is there some API or permission changes to ios17?

not according to Apple's own documentation

Bildschirmfoto 2023-06-30 um 21 28 47 Bildschirmfoto 2023-06-30 um 21 31 03 Bildschirmfoto 2023-06-30 um 21 31 24

I feel weird too, but I'm not very good at swift. I think you can download a iOS 17 emulator and try it out, it's 100% reproduced in my case.

@kalismeras61
Copy link

I have same issue...

@kalismeras61
Copy link

@manylittlestorms
Copy link

@IVLIVS-III i think it is related to below.

https://developer.apple.com/documentation/technotes/tn3152-migrating-to-the-latest-calendar-access-levels

@builttoroamadmin This seems very important. We probably need an update.

@kalismeras61
Copy link

@IVLIVS-III or @builttoroamadmin is it possible to help here ?

@Allenxuxu
Copy link
Author

@IVLIVS-III i think it is related to below.
https://developer.apple.com/documentation/technotes/tn3152-migrating-to-the-latest-calendar-access-levels

@builttoroamadmin This seems very important. We probably need an update.

I tested it, as long as I give the APP full permissions in the settings (full access to events), I can use it normally.
This package just request write-only access to events now.
Therefore, I think we should only need to update the package code, just request full access to events permissions

@kalismeras61
Copy link

any update on this ?

@junqi
Copy link
Contributor

junqi commented Sep 10, 2023

@kalismeras61
I submitted a workaround PR (#497)

You can try it by the following steps.

  1. modify pubspec.yaml as follows.
device_calendar:
  git:
    url: git://github.com/junqi/device_calendar.git
    ref: fix/ios17-request-permissions
  1. pub get
  2. add the following to your Info.plist
<key>NSCalendarsFullAccessUsageDescription</key>
<string>Access most functions for calendar viewing and editing.</string>

@IVLIVS-III
Copy link
Contributor

I tested it, as long as I give the APP full permissions in the settings (full access to events), I can use it normally.
This package just request write-only access to events now.
Therefore, I think we should only need to update the package code, just request full access to events permissions

@Allenxuxu I just tested the example app (current state of develop branch, commit hash 3c24520) on iOS Simulator on iOS 17.0 and it "just works" fine. I get two prompts:

  1. request access (write-only) on app launch
  2. request full access, when trying to read events for the first time

What did you do differently?

A screen recording is attached below.

permissions.mov

@YWD
Copy link

YWD commented Oct 30, 2023

Hello,When will this problem be solved?

@kalismeras61
Copy link

kalismeras61 commented Oct 30, 2023

device_calendar:
git:
url: git://github.com/junqi/device_calendar.git
ref: fix/ios17-request-permissions

Use package as below

device_calendar:
    git:
      url: https://github.com/builttoroam/device_calendar.git
      ref: develop
      
      
and don't forget to add       info.plist

<key>NSCalendarsFullAccessUsageDescription</key>
<string>We need access to schedule calendar</string>

@istornz
Copy link

istornz commented Nov 2, 2023

Do we have any estimated time when develop will be merged in stable?

Thanks 👍

@manylittlestorms
Copy link

Do we have any estimated time when develop will be merged in stable?

Thanks 👍

I have the same question 👍

@Zahid046
Copy link

we need an update asap, as its affecting ios 17 user

@Allenxuxu
Copy link
Author

Maybe this PR is useful:
Baseflow/flutter-permission-handler#1220

@stephenjen
Copy link

@kalismeras61 's method worked for me

@JRSil
Copy link

JRSil commented Dec 6, 2023

Do we have any estimated time when develop will be merged in stable?

Thanks 👍

Any update of it?

@narritt
Copy link

narritt commented Dec 26, 2023

device_calendar:
    git:
      url: https://github.com/builttoroam/device_calendar.git
      ref: develop

<key>NSCalendarsFullAccessUsageDescription</key>
<string>We need access to schedule calendar</string>

Not the best way to fix it, because now the application requires full calendar access even if I need to add an event.

@thomassth
Copy link
Contributor

device_calendar:
    git:
      url: https://github.com/builttoroam/device_calendar.git
      ref: develop

<key>NSCalendarsFullAccessUsageDescription</key>
<string>We need access to schedule calendar</string>

Not the best way to fix it, because now the application requires full calendar access even if I need to add an event.

What's the difference between the 2 APIs? Are they for different things, or it's like a tiered system?

@devly13
Copy link

devly13 commented Dec 31, 2023

I have two errors using the GitHub Api:
Swift Compiler Error (Xcode): Value of type 'EKEventStore' has no member
'requestFullAccessToEvents'
Swift Compiler Error (Xcode): Type 'EKAuthorizationStatus' has no member
'fullAccess'

any ideas?

@scolnet
Copy link

scolnet commented Feb 5, 2024

Hello guys,

To complete this issue, and after fork master and merge with this pull request : #519
You can have another problem with real iphone devices to create calendar with the same exception PlatformException(500, That account does not allow calendars to be added or removed., null, null)

The problem is the getSource function (in SwiftDeviceCalendarPlugin.swift) which may don't retrieve the right account (for exemple, if you have several accounts gmail and neither iCloud account by default nor local account)

$0.sourceIdentifier == "iCloud" I don't know if it has been changed in iOS 17 but sourceIdentifier return an identifier like uuid
the "iCloud" is in the title attribute.
Also, I use the default Source in fallback solution.

So, when I test with `private func getSource() -> EKSource? {

  let localSources = eventStore.sources.filter { $0.sourceType == .local }

  if (!localSources.isEmpty) {
    return localSources.first
  }

  let iCloudSources = eventStore.sources.filter { $0.sourceType == .calDAV && $0.title == "iCloud" }

  if (!iCloudSources.isEmpty) {
    return iCloudSources.first
  }

  if let defaultSource = eventStore.defaultCalendarForNewEvents?.source {
    return defaultSource
  }

  return nil
}`

It's run perfectly on real device.
Hope this helps

@peng093
Copy link

peng093 commented Apr 16, 2024

I have two errors using the GitHub Api: Swift Compiler Error (Xcode): Value of type 'EKEventStore' has no member 'requestFullAccessToEvents' Swift Compiler Error (Xcode): Type 'EKAuthorizationStatus' has no member 'fullAccess'

any ideas?
I have the same problem

@stephenjen
Copy link

I still encountered this issue yesterday where I got [(401, That account does not allow calendars to be added or removed., null, null)] after granting full access to calendars and then trying to retrieve calendars using:

await _deviceCalendarPlugin.retrieveCalendars()

I'm running iOS 17.2 on the stimulator.

Where I differ from the OP is instead of restarting my app, I noticed that if when I navigate to another screen that also uses this package and then navigate back to the screen where I encountered this issue, then my calendars would get retrieved without error.

After some trial and error, I realized that before await _deviceCalendarPlugin.retrieveCalendars() I need to first do a permission check by first running:

await _deviceCalendarPlugin.requestPermissions();

Before I would only run await _deviceCalendarPlugin.hasPermissions() before trying to retrieve calendars with await _deviceCalendarPlugin.retrieveCalendars().

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests