Skip to content

Commit ffb2a32

Browse files
committed
Fail listing of calendars when access not granted
1 parent 2b309a9 commit ffb2a32

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ios/Calendar.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,15 @@ - (void) openCalendar:(CDVInvokedUrlCommand*)command {
488488
- (void) listCalendars:(CDVInvokedUrlCommand*)command {
489489
[self.commandDelegate runInBackground: ^{
490490
NSArray * calendars = [self.eventStore calendarsForEntityType:EKEntityTypeEvent];
491+
492+
if (calendars == nil) {
493+
CDVPluginResult* pluginResult =
494+
[CDVPluginResult resultWithStatus: CDVCommandStatus_ERROR messageAsString:
495+
@"Calendars could not be listed. Is access to the Calendar blocked for this app?"];
496+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
497+
return;
498+
}
499+
491500
NSMutableArray *finalResults = [[NSMutableArray alloc] initWithCapacity:calendars.count];
492501
for (EKCalendar *thisCalendar in calendars) {
493502
NSString *type = [[NSArray arrayWithObjects:@"Local", @"CalDAV", @"Exchange", @"Subscription", @"Birthday", @"Mail", nil] objectAtIndex:thisCalendar.type];

0 commit comments

Comments
 (0)