Closed butaminas closed 5 years ago
Hi @butaminas, the code for enabling geolocation and watcher that you've posted above looks good, and that is the way to track while an app is suspended in iOS:
info.plist
. This is needed for Always authorization.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App requires GPS to track stuff</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App requires GPS to track stuff</string>
geolocation.enableLocationRequest(true)
(true
param stands for Always authorization)geolocation.watchLocation()
In Android, you can use geolocation.watchLocation()
again, however, the background tracking should be implemented in a service class like the BackgroundService
class in the TS demo of the plugin.
Regarding tracking location when the app is closed, I am not sure if it is possible in any OS at all.
Let me know if you have further questions.
Regarding tracking location when the app is closed, I am not sure if it is possible in any OS at all.
What about apps like Google Maps? In privacy settings it has 3 options for tracking location:
The 3rd options (always) allows you to track location even when the app isn't in use:
Other apps will ask for access to your location even when the app isn't in use. When you allow an app to always use your location, iOS will remind you which apps are able to use your location after an app uses your location in the background.
Reference: https://support.apple.com/en-us/HT203033 ("Give apps permission to use your Location" section)
Is there any way to achieve this using nativescript and this geolocation plugin?
:wave: @butaminas, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please, use Stackoverflow to get help.
Regarding tracking location when the app is closed, I am not sure if it is possible in any OS at all.
What about apps like Google Maps? In privacy settings it has 3 options for tracking location:
- Never
- While using the App
- Always
The 3rd options (always) allows you to track location even when the app isn't in use:
Other apps will ask for access to your location even when the app isn't in use. When you allow an app to always use your location, iOS will remind you which apps are able to use your location after an app uses your location in the background.
Reference: https://support.apple.com/en-us/HT203033 ("Give apps permission to use your Location" section)
Is there any way to achieve this using nativescript and this geolocation plugin?
Anybody knows how to request the "Always" option (on Android) with this plugin?
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
Please, tell us how to recreate the issue in as much detail as possible.
I'm trying to get geolocation when the app is closed (not when suspended, but when closed). As I understand, I need to use
enableLocationRequest
with 'true' parameter but if I do this, the location is not being tracked at all.What's the proper way to make location tracking even when the app is closed and will this also work on Android?
Is there any code involved?
For enabling geolocation:
watcher for geolocation:
By the way, I'm using VUE over here.