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(401, The user has not allowed this application to modify their calendar(s), null, null) #561

Open
FySanta opened this issue Oct 8, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@FySanta
Copy link

FySanta commented Oct 8, 2024

ios 17.0
var calendarsResult = await _deviceCalendarPlugin.retrieveCalendars() has error PlatformException(401, The user has not allowed this application to modify their calendar(s), null, null)

await _deviceCalendarPlugin.requestPermissions();
await _deviceCalendarPlugin.hasPermissions();
var calendarsResult = await _deviceCalendarPlugin.retrieveCalendars();

31728382804_ pic
errorcode:599
errorMessage:Device calendar plugin ran into an issue. Platform specific exception [401], with message :"The user has not allowed this application to modify their calendar(s)", has been thrown.

When getting the fullaccess privileges for a calendar, running await _deviceCalendarPlugin.requestPermissions() gives true after the user grants the privileges, but await _deviceCalendarPlugin.hasPermissions() says is false, and only becomes true after restarting the app.

@FySanta FySanta added the bug Something isn't working label Oct 8, 2024
@IVLIVS-III
Copy link
Contributor

make sure that this line of code await _deviceCalendarPlugin.hasPermissions(); returns true. Otherwise permissions have not been granted.

@FySanta
Copy link
Author

FySanta commented Oct 9, 2024

确保此行代码await _deviceCalendarPlugin.hasPermissions();返回true。否则权限未授予。

It shows authorized inside the app settings, but await _deviceCalendarPlugin.hasPermissions() return false

@FySanta
Copy link
Author

FySanta commented Oct 9, 2024

91728439398_ pic

@IVLIVS-III
Copy link
Contributor

That is strange, can you provide a minimum example to reproduce this issue?

@FySanta
Copy link
Author

FySanta commented Oct 9, 2024

That is strange, can you provide a minimum example to reproduce this issue?

Here's my running order

await _deviceCalendarPlugin.requestPermissions(); 
await _deviceCalendarPlugin.hasPermissions(); 
var calendarsResult = await _deviceCalendarPlugin.retrieveCalendars();

You can check separately the permission status returned by these two lines of code.

await _deviceCalendarPlugin.requestPermissions(); 
await _deviceCalendarPlugin.hasPermissions(); 

@achapkey
Copy link

achapkey commented Nov 2, 2024

Ran into the similar issue. Could not get permission request at all. It even didn't appear in system settings. Worked it around via requesting the permission from permission_handler, but it requires relaunching the app to retrieve the calendar list. Moreover, it reproduces only on 17.0, on 17.2 and higher works like charm (couldn't get my hands on iOS 17.1).

@HatsuneMikuV
Copy link

HatsuneMikuV commented Nov 5, 2024

private func requestPermissions(completion: @escaping (Bool) -> Void) {
        if hasEventPermissions() {
            completion(true)
            return
        }
        if #available(iOS 17, *) {
            eventStore.requestFullAccessToEvents {
                (accessGranted: Bool, _: Error?) in
                completion(accessGranted)
            }
        } else {
            eventStore.requestAccess(to: .event, completion: {
                (accessGranted: Bool, _: Error?) in
                completion(accessGranted)
            })
        }
    }
    private func requestPermissions(_ result: @escaping FlutterResult) {
        if hasEventPermissions()  {
            result(true)
        }
        eventStore.requestAccess(to: .event, completion: {
            (accessGranted: Bool, _: Error?) in
            result(accessGranted)
        })
    }
    

private func requestPermissions(completion: @escaping (Bool) -> Void) {

private func requestPermissions(_ result: @escaping FlutterResult) {

It should be caused by two methods with the same name

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

4 participants