-
Notifications
You must be signed in to change notification settings - Fork 291
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
iOS 17 issues: unable to request permissions #440
Comments
if the library is not updated until new iOS is released (probably 12th Sept) you can use this commit that fixes calendar and gives full permission on request: andrejguran@f876567 |
This works perfectly, thank you! |
@RhysTowey any plans to release something before the official release on 9/18 so we can get this shipped before users start updating? |
@andrejguran could you please submit a pull request for your fix? I'm hoping @wmcmahan can approve it soon. |
@RhysTowey it's more complicated than that. New apple logic has 2 modes Since for our needs we never need |
@andrejguran thank you for the iOS17 permission changes!! @RhysTowey I ran with those and went a bit further to implement the writeOnly functionality on my fork. I too only need full access so I have not tested it out, but could provide a starting point. Note though that I made a number of other changes including some breaking ones to unify the API across iOS and Android for our use case so its not a direct plug and play. |
I've tried working off of both the aforementioned branches, and I'm still having an issue where It's not prompting me for permissions and I'm always getting |
@jakehasler Have you added the new NSCalendarsFullAccessUsageDescription permission to your Info.plist? |
Welp, that was it. I had the original permission but had neglected to add the new one. All is good. Thanks so much @mysport12. |
Appreciate if a new version can be released with the fix |
is this going to be fixed? the last commit was a year ago, is this library maintained? |
how can I use this? |
Same issue , i got this error :
|
You should be able to use it like this in your package.json
|
Thanks! |
I've tried implementing this fix, but I'm getting these errors on
|
Hi, @andrejguran @mysport12 I'm on IOS 17.2 and have done everything you said, but when I call |
See discussion above. You likely missed adding the new info.plist string for full calendar access. |
@mysport12 I'm so happy that you replied my question. upon closer inspection, i found out that i really didn't add |
I debugged this further, it's a deprecation issue. I logged the error from RNCalendarEvents.m:765 and the error from the callback says the following. Printing description of ((_NSBPlistMappedString *)0x8d7a9589435cdad2):
-requestAccessToEntityType:completion: has been deprecated-calling this method is no longer allowed.
Instead, use -requestFullAccessToEventsWithCompletion:, -requestWriteOnlyAccessToEventsWithCompletion:, or -requestFullAccessToRemindersWithCompletion:. Edit: I edited requestPermissions to the following: RCT_EXPORT_METHOD(requestPermissions:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
if (@available(iOS 17.0, *)) {
[self.eventStore requestFullAccessToEventsWithCompletion:^(BOOL granted, NSError *error) {
NSString *status = granted ? @"authorized" : @"denied";
if (!error) {
resolve(status);
} else {
reject(@"error", @"authorization request error", error);
}
}];
} else {
[self.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
NSString *status = granted ? @"authorized" : @"denied";
if (!error) {
resolve(status);
} else {
reject(@"error", @"authorization request error", error);
}
}];
}
} |
@daxaxelrod thanks dude! It is working well right now👍👏 |
@daxaxelrod thanks for the fix. I opened a pull request to get this fix in the main repo: |
In my case once the user deny the the permission access, It does not ask for permissions again on respective screen. useEffect(() => { const calendarPermissions = async () => { |
hey did you find any solution ? |
unauthorized to access calendar error using permission: NSCalendarsWriteOnlyAccessUsageDescription and created event with permission: NSCalendarsFullAccessUsageDescription.Do I need a write-only access permission instead of full access for iOS 17? componentDidMount() { |
For our app we only want to request write only access for iOS, but using @daxaxelrod their fix and changing To resolve this we created a separate boolean returning if write only access has been granted and in Below - (BOOL)isCalendarWriteOnlyAccessGranted
{
EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
if (@available(iOS 17.0, *)) {
return status == EKAuthorizationStatusWriteOnly;
}
return false;
} And I edited RCT_EXPORT_METHOD(saveEvent:(NSString *)title
settings:(NSDictionary *)settings
options:(NSDictionary *)options
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
if (![self isCalendarAccessGranted] && ![self isCalendarWriteOnlyAccessGranted]) {
reject(@"error", @"unauthorized to access calendar", nil);
return;
}
NSMutableDictionary *details = [NSMutableDictionary dictionaryWithDictionary:settings];
[details setValue:title forKey:_title];
__weak RNCalendarEvents *weakSelf = self;
dispatch_async(serialQueue, ^{
@try {
RNCalendarEvents *strongSelf = weakSelf;
NSDictionary *response = [strongSelf buildAndSaveEvent:details options:options];
if ([response valueForKey:@"success"] != [NSNull null]) {
resolve([response valueForKey:@"success"]);
} else {
reject(@"error", [response valueForKey:@"error"], nil);
}
}
@catch (NSException *exception) {
reject(@"error", @"saveEvent error", [self exceptionToError:exception]);
}
});
} And if everything's correct you can write events using Full Access or WriteOnly Access permissions! 🎉 |
@voslartomas thanks, with your commit, i got it works very good. this is the code snippet: // ios/myProjectName/Info.plist
// tsx code const handleClick = useCallback(() => {
RNCalendarEvents.requestPermissions().then(
(result) => {
Alert.alert('Auth requested', result);
createEvent();
},
(result) => {
console.error(result);
},
);
}, [])
const createEvent = async () => {
const eventDetails = {
title: 'New Event',
startDate: new Date().toISOString(), // Start date
endDate: new Date(new Date().getTime() + 60 * 60 * 1000).toISOString(), // End date (1 hour later)
description: 'This is a test event',
location: 'Somewhere',
};
// Check for existing events
const events = await RNCalendarEvents.fetchAllEvents(eventDetails.startDate, eventDetails.endDate);
const isDuplicate = events.some((event) => event.title === eventDetails.title);
if (isDuplicate) {
Alert.alert('Duplicate Event', 'This event already exists in your calendar.');
return;
}
// Save the new event
RNCalendarEvents.saveEvent(eventDetails.title, eventDetails)
.then((id) => {
console.log(`Event created with ID: ${id}`);
Alert.alert('Success', 'Event created successfully!');
})
.catch((error) => {
console.error('Error creating event:', error);
Alert.alert('Error', 'Failed to create event.');
});
};
` |
I am running iOS 17 beta with XCode 15 beta and i'm getting issues when requesting permissions using this library. Works fine with iOS 16. Seems as if Apple have changed the Calendar permissions API on iOS 17:
https://developer.apple.com/documentation/eventkit/accessing_calendar_using_eventkit_and_eventkitui#4250785
Environment
react: 17.0.2
react-native: 0.67.2
react-native-calendar-events: 2.2.0
Steps to Reproduce
Added the following to
Info.plist
(I've tried using just either one but same result)
Requesting permissions:
Checking permissions:
Actual Behavior
Requesting permissions response:
Checking permissions response:
The text was updated successfully, but these errors were encountered: