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

Cherry pick request FullAccess on iOS17+ (#497) #519

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ jobs:
flutter build apk
test-ios:
name: iOS build test
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0.1'
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,11 @@ For iOS 10+ support, you'll need to modify the `Info.plist` to add the following
<string>Access contacts for event attendee editing.</string>
```

For iOS 17+ support, add the following key/value pair as well.

```xml
<key>NSCalendarsFullAccessUsageDescription</key>
<string>Access most functions for calendar viewing and editing.</string>
```

Note that on iOS, this is a Swift plugin. There is a known issue being tracked [here](https://github.com/flutter/flutter/issues/16049) by the Flutter team, where adding a plugin developed in Swift to an Objective-C project causes problems. If you run into such issues, please look at the suggested workarounds there.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 30
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
minSdkVersion 19
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand Down
21 changes: 16 additions & 5 deletions ios/Classes/SwiftDeviceCalendarPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -916,15 +916,26 @@ public class SwiftDeviceCalendarPlugin: NSObject, FlutterPlugin, EKEventViewDele
completion(true)
return
}
eventStore.requestAccess(to: .event, completion: {
(accessGranted: Bool, _: Error?) in
completion(accessGranted)
})
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 hasEventPermissions() -> Bool {
let status = EKEventStore.authorizationStatus(for: .event)
return status == EKAuthorizationStatus.authorized
if #available(iOS 17, *) {
return status == EKAuthorizationStatus.fullAccess
} else {
return status == EKAuthorizationStatus.authorized
}
}

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