I’m working on a Capacitor app that is using the @capacitor/geolocation
plugin and I’m using v5.0.6.
Premise:
I need to check if the user has already given to the app the permission to access his location and looking at the @capacitor/geolocation
plugin docs I saw that there is a checkPermission
method that should do the work.
Wanted behavior:
I need to check if the app can access the user location and then I’ll have to implement some custom logic. That logic doesn’t require the opening of the native dialog box, so my idea was to just call the checkPermission
method and implement some if statement based on the return value I’ll get.
Actual behavior:
Invoking the checkPermission
method will open the native dialog box that will prompt the user to give the permission to access his location.
Question:
Why the Geolocation.checkPermissions()
method is opening the native dialog box ? Shouldn’t it just return the two info about location
and coarseLocation
? Am I experiencing a bug of @capacitor/geolocation
plugin or is that the wanted behavior ? If this is the wanted behavior, there is a way to not open the native dialog box when checking the location permission ?
Version:
@capacitor/geolocation: 5.0.6