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

Not enabling 'Precise' location on iOS does not error out #115

Open
jhp0621 opened this issue May 9, 2024 · 2 comments
Open

Not enabling 'Precise' location on iOS does not error out #115

jhp0621 opened this issue May 9, 2024 · 2 comments

Comments

@jhp0621
Copy link

jhp0621 commented May 9, 2024

Describe the bug
On Android, if I don't provide "precise" location data permission (just "approximate"), the addWatcher method returns an error in the callback function with the code "NOT_AUTHORIZED", but on iOS, there is no error and tracking starts. We need precise location for our usage.

To Reproduce
Steps to reproduce the behavior:

  1. Create an app that uses this plugin
  2. Set the addWatcher method
  3. Allow location permission on the app but not 'precise' (on Android: choose 'approximate'; on iOS: toggle off 'precise location')
  4. On an Android device, the plugin throws an error "NOT_AUTHORIZED" but on an iOS device, it does not and the location tracking begins.

Expected behavior
iOS behaves the same way as Android: error is present in the addWatcher method's callback function if "precise location" is not granted by the user

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: iPhone 14 Pro
  • OS: iOS17.4.1

Additional context
Add any other context about the problem here.

@jhp0621 jhp0621 changed the title Not enable Not enabling 'Precise' location on iOS does not error out May 9, 2024
@diachedelic
Copy link
Collaborator

If you can find a solution I will incorporate it into the plugin. This is probably the best place to start looking:

if call.getBool("requestPermissions") != false {
let status = CLLocationManager.authorizationStatus()
if [
.notDetermined,
.denied,
.restricted,
].contains(status) {
return (
background
? manager.requestAlwaysAuthorization()
: manager.requestWhenInUseAuthorization()
)
}
if (
background && status == .authorizedWhenInUse
) {
// Attempt to escalate.
manager.requestAlwaysAuthorization()
}
}
.

@GerardoTovar
Copy link

A temporary fix. What I did is force the user to choose the precision option and always use it when the app is active.
This can be achieved using the cordova-diagnostic-plugin plugin but you still have to implement some complex permission request logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants