ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
518 stars 583 forks source link

navigator.getCurrentPosition re-prompts for location permission even if @capacitor/geolocation has permission #2006

Open rahbu opened 8 months ago

rahbu commented 8 months ago

Bug Report

Plugin(s)

@capacitor/geolocation ^5.0.6

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 5.6.0
  @capacitor/core: 5.6.0
  @capacitor/android: 5.6.0
  @capacitor/ios: 5.6.0

Installed Dependencies:

  @capacitor/android: not installed
  @capacitor/core: 5.6.0
  @capacitor/cli: 5.6.0
  @capacitor/ios: 5.6.0

Platform(s)

iOS (Android not tested)

Current Behavior

On device (iPhone 12 Pro with iOS 17.2.1), calls to navigator.getCurrentPosition initially re-prompt for location permission even if @capacitor/geolocation's Geolocation has permission. To reproduce, add @capacitor/geolocation and a button for each of the calls to one of the default Ionic apps. Calls to Geolocation.requestPermissions and Geolocation.getCurrentPosition work as expected but navigator.geolocation.getCurrentPosition produces a new prompt asking for permission. Closing the app and repeating the procedure produces the same behavior. Closing the app and repeating for the third time now has navigator.geolocation.getCurrentPosition succeed without a further permission prompt.

https://github.com/ionic-team/capacitor-plugins/assets/113043422/096c8b6a-1331-42ec-ab7d-90bdc178d8fc

Expected Behavior

If location permissions have been granted, calls to navigator.geolocation.getCurrentPosition should proceed without a further prompt.

Code Reproduction

GitHub - rahbu/geolocation-example

Other Technical Details

Additional Context

Similar issues have been resolved by injecting Platform and waiting for Platform.ready(), but that produces no change here.

ionitron-bot[bot] commented 7 months ago

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.