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

Add support for iOS 17 and fix the non-access problem for calendars #566

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
26 changes: 10 additions & 16 deletions src/ios/Calendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,16 @@ - (void) pluginInitialize {
}

- (void) initEventStoreWithCalendarCapabilities {
__block BOOL accessGranted = NO;
EKEventStore* eventStoreCandidate = [[EKEventStore alloc] init];
if([eventStoreCandidate respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
[eventStoreCandidate requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
accessGranted = granted;
dispatch_semaphore_signal(sema);
}];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
} else { // we're on iOS 5 or older
accessGranted = YES;
}

if (accessGranted) {
self.eventStore = eventStoreCandidate;
}
EKEventStore* eventStoreCandidate = [[EKEventStore alloc] init];

[eventStoreCandidate requestFullAccessToEventsWithCompletion:^(BOOL granted, NSError *error) {
if (granted) {
self.eventStore = eventStoreCandidate;
NSLog(@"Full access to the event store granted and eventStore initialized.");
} else {
NSLog(@"Access to the event store not granted. Error: %@", error.localizedDescription);
}
}];
}

#pragma mark Helper Functions
Expand Down