-
Notifications
You must be signed in to change notification settings - Fork 68
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
Background location doesn't work in Android >= 10 (API level 29) #19
Comments
I'm not sure there's an actual issue here. My users have android 10 and 11 and are using this plugging successfully. |
Hmmm... This is a bit confusing! I've read through the comments on that issue you linked in the PR, and there's really quite a few people seeing issues with this. |
Yes. |
I've been doing some testing with my app and the plugin on Android, and it's all over the place. I'm still looking at it, and have still to fully understand it, but I did find this in the Android docs here:
From what I can understand, unless |
If I understood your question then yes. You have to set stratForground to true so that the app will start a service in foreground mode to be able to collect location while the app in not in the front. When clicking a button to start this service you make sure that the service is created when the app is in the foreground and avoid the above pitfall. |
Hello all, const config: BackgroundGeolocationConfig = {
bgWork function is where I send data to server. The app must send location data to a server backend even if is in background but it seems doesn't work for me. I see notification for foreground service but how can I send data when app is in background? Can you help me? |
This won't work in general as explained in this thread. |
Is the following configuration correct to send data through plugin's http native calls? const config: BackgroundGeolocationConfig = { |
I'm not using the url part of the plugin, but I guess it should work. |
@HarelM I have tried but when app is active it calls the url http://192.168.1.130:3000/api/v1/trips/test but when in background it does nothing. If BACKGROUND_GEOLOCATION permission isn't added how can the app locate you position and so send it to backend? |
@francescognarra there's a misconception about the definition of background and foreground and this permission. |
Is your plugin defined as |
@HarelM another question: I'm using original plugin from mauron85/cordova-plugin-background-geolocation. Should I use this HaylLtd/cordova-background-geolocation-plugin and, if so, how can I point to this? |
How can I check this? |
On the configuring of the plugin you can specify to use foreground service (configure method). |
@HarelM I have installed your plugin and it seems to work :D |
You need to make sure the app doesn't get killed by the OS. |
@HarelM Sorry for the delay! Yep, I'll close this as |
still not sure where that goes! |
https://haylltd.github.io/cordova-background-geolocation-plugin/api.html |
My app seems to be working fine in the background and foreground without the startForeground though!! am I missing here? |
It will probably stop after a while if you won't assign it to start as a foreground service... |
Hi @HarelM , |
The following is the code I use in my app: |
Describe the bug
Background location updates are blocked on Android >=10 (API level 29) due to missing permissions.
Expected behavior
The plugin should include the permissions necessary to enable background location tracking on Android >=10 (API level 29).
According to the docs, the plugin must include the
ACCESS_BACKGROUND_LOCATION
permission.The text was updated successfully, but these errors were encountered: