bug: Geolocation.getCurrentPosition throws error on new permission dialog on iOS 14.2
See original GitHub issueBug Report
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 2.4.2
@capacitor/core: 2.4.2
@capacitor/android: 2.4.2
@capacitor/electron: 2.4.2
@capacitor/ios: 2.4.2
Installed Dependencies:
@capacitor/android not installed
@capacitor/cli 2.4.2
@capacitor/core 2.4.2
@capacitor/ios 2.4.2
@capacitor/electron not installed
Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌
Platform(s)
iOS 14.2
Current Behavior
Calling the getCurrentPosition API results in failure during the permission check on iOS 14.2 only. Seemingly the call times out after 2 seconds of waiting on the permission dialog. Console Output from XCode via emulator:
To Native -> Geolocation getCurrentPosition 80463459 APP INACTIVE ERROR MESSAGE: {“message”:“The operation couldn’t be completed. (kCLErrorDomain error 1.)”,“errorMessage”:“The operation couldn’t be completed. (kCLErrorDomain error 1.)”} ⚡️ [error] - ERROR Error: Uncaught (in promise): Error: The operation couldn’t be completed. (kCLErrorDomain error 1.)
Expected Behavior
getCurrentPosition should wait until an option has been selected on the permission dialog.
Code Reproduction
Basic reproduction. Simply hit the ‘test’ button on tab 1 and you will see the above error in the xcode console. https://github.com/abarax/capacitor-bug
Only Code added is here:
To run:
npm run build npx cap sync npx cap open ios
Run via XCode using iOS 14.2 simulator
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10 (2 by maintainers)
Top GitHub Comments
@zsyphon Right now our workaround is to sit in a loop checking permissions using the query permission API (https://capacitorjs.com/docs/apis/permissions) Once the permission is recognised, only then do we use getCurrentPosition.
I would love to dig in and figure out the cause here, I suspect something changed in the iOS operating system update. I actually think this was not happening on 14.2 beta as well, which is interesting.
2.4.3 is out with this fix.