Skip to content

Commit

Permalink
Request FullAccess on iOS17+ (#497)
Browse files Browse the repository at this point in the history
* fix: request FullAccess on iOS17 or later

* update iOS integration description

* fix: iOS build test & Android build test
  • Loading branch information
junqi authored Sep 16, 2023
1 parent 3c24520 commit 623f0bf
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
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-beta'
- 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 @@ -111,4 +111,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"
consumerProguardFiles 'proguard-rules.pro'
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.builttoroam.devicecalendarexample"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 31
versionCode 1
versionName "1.0"
Expand Down
21 changes: 16 additions & 5 deletions ios/Classes/SwiftDeviceCalendarPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1056,15 +1056,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
}
}
}

Expand Down

0 comments on commit 623f0bf

Please sign in to comment.