question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Geolocation.getCurrentPosition throws error on new permission dialog on iOS 14.2

See original GitHub issue

Bug 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.)

CleanShot 2020-11-11 at 17 47 37@2x

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:

https://github.com/abarax/capacitor-bug/blob/main/src/app/explore-container/explore-container.component.ts

https://github.com/abarax/capacitor-bug/blob/main/src/app/explore-container/explore-container.component.html

To run:

npm run build npx cap sync npx cap open ios

Run via XCode using iOS 14.2 simulator

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
abaraxcommented, Nov 15, 2020

@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.

2reactions
imhoffdcommented, Nov 18, 2020

2.4.3 is out with this fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Phonegap IOS geolocation permission alert not showing
I was fighting with this issue for few days and I finally got the solution. Seems like its not plugin nor corvoda version...
Read more >
Multiple permission prompting for … | Apple Developer Forums
There seems to be the same underlying problem causing this behavior with WKWebView. As it seems there is a problem with managing/mapping the...
Read more >
navigator.geolocation.getCurrentPosition always throws ...
3) If "Access Your Location" is set to "Allow", running the snippet skips the permission dialog and immediately throws the "User denied" error....
Read more >
CHANGELOG Reference
Feature: Added a new interface getMessagingUnique in ... This error will be thrown from SDK if any API from platform sends 429 status...
Read more >
WP1 Standardization Report - HTML5 Apps
(OWP), iOS, Android, Windows Phone, Chrome Apps, Firefox OS and General ... then followed by the operating system generated permissions dialogue. If the....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found