Skip to content

Commit

Permalink
Cherry pick request FullAccess on iOS17+ (#497) (#519)
Browse files Browse the repository at this point in the history
* Request FullAccess on iOS17+ (#497)

* fix: request FullAccess on iOS17 or later

* update iOS integration description

* fix: iOS build test & Android build test

* feat: update xcode-version

* update changelog and pubspec

* fix ci

---------

Co-authored-by: MIYANARI Junki <[email protected]>
  • Loading branch information
LeonardoCaracho and junqi authored Feb 28, 2024
1 parent f7f3bb0 commit bc7bccb
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 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.1'
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<!-- To benefit from the current changelog reader in CI/CD, please follow the changelog format from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -->

## [4.3.3](https://github.com/builttoroam/device_calendar/releases/tag/4.3.3)

- Fixed an [issue](https://github.com/builttoroam/device_calendar/issues/490) that prevented the plugin from being used with iOS 17+

## [4.3.2](https://github.com/builttoroam/device_calendar/releases/tag/4.3.2)

- Removed unnecessary package to reduce build error
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
4 changes: 3 additions & 1 deletion example/lib/presentation/pages/calendar_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,9 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
ElevatedButton(
key: const Key('deleteEventButton'),
style: ElevatedButton.styleFrom(
primary: Colors.red, onPrimary: Colors.white),
foregroundColor: Colors.white,
backgroundColor: Colors.red,
),
onPressed: () async {
bool? result = true;
if (!_isRecurringEvent) {
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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: device_calendar
description: A cross platform plugin for modifying calendars on the user's device.
version: 4.3.2
version: 4.3.3
homepage: https://github.com/builttoroam/device_calendar/tree/master

dependencies:
Expand Down

0 comments on commit bc7bccb

Please sign in to comment.