-
Notifications
You must be signed in to change notification settings - Fork 59
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
There should be permission Allow All time #58
Comments
You may be experiencing #14, whereby HTTP requests made from the WebView are throttled in the background. |
I tried this plugin and it's not #14, I've also added that http. Once I manually go to app info and set the permissions to always, I start getting locations when app is in the background and it's sent just fine. I tried updating permissions to have ACCESS_BACKGROUND_LOCATION but it still didn't ask for it when asking for permissions. |
Which versions of Android do you see this problem on? |
I'm testing on Pixel 6, Android version 12 |
If anyone discovers a solution please let me know. |
I was confused about this as well, but I found this text at https://developer.android.com/training/location/permissions On Android 11 (API level 30) and higher, however, the system dialog doesn't include the Allow all the time option. Instead, users must enable background location on a settings page, as shown in figure 7. |
It looks like this plugin is using a foreground service to access the location rather than require the ACCESS_BACKGROUND_LOCATION permission, so you don't have the option to allow all the time. As long as the app is running even in the background, the foreground service should continue to access the location without the ACCESS_BACKGROUND_LOCATION permission, correct? Edit: I found some more information here on when ACCESS_BACKGROUND_LOCATION is required if using a foreground service: https://developer.android.com/guide/components/foreground-services Another edit: According to the documentation you should only need ACCESS_BACKGROUND_LOCATION if the foreground service is started by an app running in the background, but I'm not having any luck without adding location access all the time. |
At least on Android 11, the "Allow only while using app" permission is sufficient to provide both foreground and background location updates. The confusion arises from the wording of the permission dialog. This wording is especially confusing if you are familiar with the permissions dialog on iOS, which uses similar wording but for a different permissions model. It is crucial to understand what is meant by "background" on both platforms. As far as Android is concerned, so long as a persistent notification is visible then the user is actively using the app, even if the app itself is not visible. It remains in the foreground in some sense. Android's permissions dialog gives the user three options:
Selecting either of the first two will be sufficient for granting "background" location updates. The ACCESS_BACKGROUND_LOCATION permission (which this plugin does not use) is more powerful. It allows the app to access the device's location at any time, without informing the user. That is why Android is so reluctant to grant it. iOS, on the other hand, uses a more intuitive permissions model. It considers the app to be backgrounded if it is not visible on the screen. Before an app can receive background locations updates, the user must choose from the following:
Choosing "Allow while using the app" will result in foreground location updates only. The next time the user sends the app to the background, they will be prompted to upgrade the permission to include background updates. The "Allow once" option provides both foreground and background location updates, but only until the app is killed. |
Hey.. I just wanted to follow up because the others may be having the same issue I was. In the device log I was seeing this message: Foreground service started from background can not have location/camera/microphone access Which is why the ACCESS_BACKGROUND_LOCATION was being required. It seems by the time the onActivityStopped() method is called, the app is already in the background, so the isLocationAvailable() method was returning false. Once I removed the onActivityStarted() and onActivityStopped() methods and started the foreground service when the watcher is created in addWatcher(), I'm starting to get consistent location updates. |
What device and OS are you using @klantz81 ? When you start the foreground service I suppose the notification is presented even whilst the app is visible? |
If you rename the |
I'm using a pixel 6 pro with android 12. Yes, when I start the foreground service in the LocalBinder::addWatcher method, the notification is presented while the app is visible. If I change the plugin methods to handleOnPause/handleOnResume, the foreground service is able to provide location updates when the app is in the background, and the notification is not presented until I put the app in the background. |
Thanks @klantz81 . This fix is released in v1.2.1 and v0.3.16, please test. |
I've checked v1.2.1, and it's working fine. Thank you! |
request permissions on ios does not work after the initial request is responded with 'Don't Allow'
native Geolocation.requestPermissions(#ID) No iOS native pop up asking for permissions, (allow, dont allow) |
I think you are using a different plugin, @jadsy2107 . See https://github.com/ionic-team/capacitor-plugins/tree/main/geolocation. However, your problems might be solved by swapping to this plugin. |
include this in your build AndroidManifest.xml file
inside the manifest tag and you should be good to go |
I have had this on my Manifest for the longest but it doesn't work, Sentry always report this issue
|
Describe the bug
I have to give allow all time permission for android to keep it working in bacckground. but this plugin allow only while using app. How i can overcome this issue. If I give while using app permssion it is not working in background
To Reproduce
Steps to reproduce the behavior:
just put application in background on call http request on location change
Expected behavior
it should work all time while in bacgkround or minimize
Smartphone (please complete the following information):
-Android 12
The text was updated successfully, but these errors were encountered: