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

Created on 11 Nov 2020  路  8Comments  路  Source: ionic-team/capacitor

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鈥檛 be completed. (kCLErrorDomain error 1.)","errorMessage":"The operation couldn鈥檛 be completed. (kCLErrorDomain error 1.)"}
鈿★笍 [error] - ERROR Error: Uncaught (in promise): Error: The operation couldn鈥檛 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

ios

Most helpful comment

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

All 8 comments

@abarax Have you made any progress on this issue? I am getting the same error.

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

Looks like jcesarmobile has a fix though!

It was happening on iOS 13 too, just took a bit longer to timeout. My PR should fix the problem.

@jcesarmobile Thank you!!

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

@abarax @jcesarmobile Thank you!!

Having the same issue..

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

@abarax have you used this approach on ios as well? I'm getting this log:
鈿★笍 [log] - This browser does not support the Permissions API

2.4.3 is out with this fix.

Was this page helpful?
0 / 5 - 0 ratings