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

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

Closed
abarax opened this issue Nov 11, 2020 · 10 comments

Comments

@abarax
Copy link

abarax commented Nov 11, 2020

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

@abarax abarax changed the title bug: Geolocation broken on iOS 14.2 bug: Geolocation throws error on new permission dialog on iOS 14.2 Nov 11, 2020
@abarax abarax changed the title bug: Geolocation throws error on new permission dialog on iOS 14.2 bug: Geolocation.getCurrentPosition throws error on new permission dialog on iOS 14.2 Nov 11, 2020
@zsyphon
Copy link

zsyphon commented Nov 13, 2020

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

@abarax
Copy link
Author

abarax commented 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.

@abarax
Copy link
Author

abarax commented Nov 16, 2020

Looks like jcesarmobile has a fix though!

@jcesarmobile
Copy link
Member

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

@zsyphon
Copy link

zsyphon commented Nov 16, 2020

@jcesarmobile Thank you!!

@zsyphon
Copy link

zsyphon commented Nov 16, 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.

@abarax @jcesarmobile Thank you!!

@ropfoo
Copy link

ropfoo commented Nov 17, 2020

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

@imhoffd
Copy link
Contributor

imhoffd commented Nov 18, 2020

2.4.3 is out with this fix.

@DwieDima
Copy link

@jcesarmobile this issue seems to persist in version 1.3.1.
If you reject Geolocation Services and then call Geolocation.getCurrentPosition(), you'll get the error message in XCode:

Operation could not be completed(KCLErrorDomain error 1.).

expected: GeolocationPositionError

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants