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

requestCalendarAuthorization() always returns DENIED_ALWAYS #512

Open
5 tasks done
yudateNoriyuki opened this issue Jan 11, 2024 · 2 comments
Open
5 tasks done

requestCalendarAuthorization() always returns DENIED_ALWAYS #512

yudateNoriyuki opened this issue Jan 11, 2024 · 2 comments

Comments

@yudateNoriyuki
Copy link

Bug report

CHECKLIST

  • I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
  • I have checked that no similar issues (open or closed) already exist.

Current behavior:

  1. Call requestCalendarAuthorization() on iOS 17.
  2. OS dialog does not appear.
  3. The successCallback consistently returns DENIED_ALWAYS.

Expected behavior:

Before granting calendar permission, the OS dialog should appear, and the response in the successCallback should vary based on the user's selection.

Steps to reproduce:

Same as described above.

Screenshots

Environment information

  • Cordova CLI version

    • 12.0.0
  • Cordova platform version

    • ios 7.0.0
  • Plugins & versions installed in project (including this plugin)

    • @ahovakimyan/cordova-plugin-wkwebviewxhrfix 1.0.1 "Cordova WKWebView File XHR Fix"
    • @havesource/cordova-plugin-push 4.0.0-dev.0 "Cordova Push Plugin"
    • com.teamnemitoff.phonedialer 0.3.0 "PhoneDialer"
    • cordova-plugin-android-permissions 1.1.5 "Permissions"
    • cordova-plugin-app-version 0.1.14 "AppVersion"
    • cordova-plugin-badge 0.8.9 "Badge"
    • cordova-plugin-calendar 5.1.6 "Calendar"
    • cordova-plugin-customurlscheme 5.0.2 "Custom URL scheme"
    • cordova-plugin-device 2.1.1-dev "Device"
    • cordova-plugin-dialogs 3.0.0-dev "Notification"
    • cordova-plugin-file-transfer 2.0.0-dev "File Transfer"
    • cordova-plugin-file 6.0.2 "File"
    • cordova-plugin-geolocation 4.1.1-dev "Geolocation"
    • cordova-plugin-inappbrowser 5.0.1-dev "InAppBrowser"
    • cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
    • cordova-plugin-market 1.2.0 "Market"
    • cordova-plugin-migrate-localstorage 0.0.2 "Migrate WebView Data"
    • cordova-plugin-nativestorage 2.3.2 "NativeStorage"
    • cordova-plugin-ondestroy 1.0.2 "Cordova onDestroy Plugin"
    • cordova-plugin-save-image 0.3.0 "SaveImage"
    • cordova-plugin-statusbar 3.0.1-dev "StatusBar"
    • cordova-plugin-wkwebview-engine 1.2.2 "Cordova WKWebView Engine"
    • cordova-plugin-x-socialsharing 6.0.4 "SocialSharing"
    • cordova-save-image-gallery 0.0.27 "saveImageGallery"
    • cordova-universal-links-plugin 1.2.1 "Universal Links Plugin"
    • cordova.plugins.diagnostic 7.1.1 "Diagnostic"
    • es6-promise-plugin 4.2.2 "Promise"
    • in.edelworks.sharedpreferences 0.1.0 "Shared Preferences"
    • phonegap-plugin-barcodescanner 8.1.1-dev "BarcodeScanner"
  • Dev machine OS and version, e.g.

    • OSX
      • 14.1.1

Runtime issue

  • Device details
    • iPhone15
  • OS details
    • iOS17.2.1
@aks7665
Copy link

aks7665 commented Feb 2, 2024

I am also facing the same problem with following versions:

Device details
iPhone14

OS details
iOS17.2.1

@yudateNoriyuki Have you found any solution?

@yudateNoriyuki
Copy link
Author

@aks7665
Yes, I was able to solve it using ChatGPT, although not perfectly.
I resolved it by modifying the following part of src/ios/Diagnostic_Calendar.m:

Before

[self.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
    [diagnostic logDebug:[NSString stringWithFormat:@"Access request to calendar events: %d", granted]];
    [diagnostic sendPluginResultBool:granted:command];
}];

After

if (@available(iOS 17, *)) {
    [self.eventStore requestFullAccessToEventsWithCompletion:^(BOOL granted, NSError *error) {
        [diagnostic logDebug:[NSString stringWithFormat:@"Access request to calendar events: %d", granted]];
        [diagnostic sendPluginResultBool:granted:command];
    }];
} else {
    [self.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        [diagnostic logDebug:[NSString stringWithFormat:@"Access request to calendar events: %d", granted]];
        [diagnostic sendPluginResultBool:granted:command];
    }];
}

This allows requesting full access to calendar permissions.
However, please note that if you're using https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin, this modification alone won't enable you to add events to the calendar. Be cautious about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants