Open FySanta opened 1 month ago
make sure that this line of code await _deviceCalendarPlugin.hasPermissions();
returns true
. Otherwise permissions have not been granted.
确保此行代码
await _deviceCalendarPlugin.hasPermissions();
返回true
。否则权限未授予。
It shows authorized inside the app settings, but await _deviceCalendarPlugin.hasPermissions()
return false
That is strange, can you provide a minimum example to reproduce this issue?
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();
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).
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)
})
}
It should be caused by two methods with the same name
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();
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.