capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
177 stars 54 forks source link

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

Open jhp0621 opened 1 month ago

jhp0621 commented 1 month ago

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):

Additional context Add any other context about the problem here.

diachedelic commented 1 month ago

If you can find a solution I will incorporate it into the plugin. This is probably the best place to start looking: https://github.com/capacitor-community/background-geolocation/blob/fe780a4c8672f7b526792c2815d6e99652a55cd7/ios/Plugin/Plugin.swift#L108-L127.

GerardoTovar commented 1 week ago

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.