react-native-background-geolocation
react-native-background-geolocation copied to clipboard
FOREGROUND_SERVICE_HEALTH
Your Environment
- Plugin version: 4.14.6
- Platform: Android
- OS version: 13
- Device manufacturer / model:
- React Native version (
react-native -v
): 72.6 - Plugin config
Issue not related directly to code. More a query.
Expected Behavior
FOREGROUND_SERVICE_LOCATION was identified when uploading bundle to Google Play Console.
Actual Behavior
"Your app uses the following undeclared foreground service permissions... FOREGROUND_SERVICE_HEALTH FOREGROUND_SERVICE_LOCATION..." I'm guessing FOREGROUND_SERVICE_HEALTH was required by your plugin? Google is requesting an explanation for have that in the app. So that I know how to answer them, could you please explain the reason for having FOREGROUND_SERVICE_HEALTH in the plugin?
Steps to Reproduce
Not relevant.
Context
Upload Android bundle to Google Play store.
Debug logs
Not relevant
PASTE_YOUR_LOGS_HERE
I'm guessing FOREGROUND_SERVICE_HEALTH was required by your plugin?
Yes. The plugin uses the Motion API (which comes under the umbrella of "Health") in order to automatically toggle location-tracking when the device is determined to be moving / stationary.
@irvinsingGitHub Mine is also getting rejected, did you manage to solve it?
You have to record a video and explain to Play Store that your app uses the "Activity Transition API" to automatically track location when the device is detected to be in-motion, in order to conserve battery power when the device is detected to be stationary".
@christocracy Thank you. Another question, what should I show them in the video exactly (for the FOREGROUND_SERVICE_HEALTH permission)? I'm not showing a map or anything I'm just tracking the location of the user in the background, the app is for the company's drivers and it mainly tracks their location when moving
I cannot say what you should show them. You need to record a video of your app and explain to them why you need to use the "Motion Transition API" to automatically trigger location tracking when devices are detected to be in-motion, and to turn off location-tracking when devices are detected to be stationary in order to conserve battery power.
@hisothreed did you manage to get the permisson?
@irvinsingGitHub Mine is also getting rejected, did you manage to solve it?
@hisothreed I wasn't using the motion detector in our app. So i decided to remove that permission from the Android manifest, and ultimately didn't have to face the issue right now.
@TNAJanssen Yes it was accepted
@hiso3d what did you end up using as the reason and the notifing of the user?
For years, this plugin has used the ActivityTransistionApi
from play-services
to know when a device is moving (in_vehicle
, on_bicycle
, on_foot
, running
) or stationary (still
). This allows the plugin to intelligently turn on location-services only when required and conserving energy when the device is stationary.
With Android 14, in order for ActivityTransition
events to trigger in the background, this API now requires the permission FOREGROUND_SERVICE_HEALTH
.
So, when providing a reason for usage of FOREGROUND_SERVICE_HEALTH
, you should say something like:
We use the Activity Transition API to intelligently enable location-tracking when the app is in the background only when the device is determined to be moving ("on bicycle", "in vehicle", "walking", etc) and to save energy by turning off location-updates when the device is determined to be stationary.
If you do remove the FOREGROUND_SERVICE_HEALTH
permission from your AndroidManifest
, the plugin will still monitor a geofence around the last known position (what I call "the stationary geofence"), the exit of which will signal that the device is in-motion (this typically requires movement of about 200 meters from the last known location).
To remove FOREGROUND_SERVICE_HEALTH
from you AndroidManifest
, add the following element:
<manifest>
<uses-permission
android:name="android.permission.FOREGROUND_SERVICE_HEALTH"
tools:node="remove" />
.
.
.
</manifest>
Removing this permission will cause your app to have a longer delay initiating location-tracking. Where tracking might occur within a few meters of movement will now take at least 200 meters.
@christocracy Is there way to optimise this. I've got reject from google.
“Optimize” what?
use WorkManger instead? or stop using health motion apis?
You don’t understand what WorkManager is.
Did you not read the comment above yours?
Our app also started to be rejected although it was already in prod with the lib. I guess we could remove the permission from the manifest, although it would have an impact (although were just using Geofencing, i assume the precision will decrease)
Did you read this?
@christocracy i had, i edited my post with that info. We are trying to increase the precision of the data collected, this is a step back for us
Then it’s up to you to follow the instructions requested by the Play Store and prove to them why you need that permission.
Yes to be honest i just replied to increase awareness as we're already doing that :)
I’m soon going to completely remove this permission from the plug-in, turning it from an opt-out to an opt-in.
We got accepted with the reason @christocracy gave us. So when describing it correctly they do allow it
@TNAJanssen we got rejected even with that reason
For us what helped was a permission screen in between asking for permission where we state why we need the health permission.
@TNAJanssen we have the "same" screen, we uploaded a video sending a user to that screen and from there asking for the permissions. Still denied. I think as usual with the stores, it really depends on who checks, theres no golden rule, you just got lucky
we have the "same" screen, we uploaded a video sending a user to that screen
Show us your video.
“Optimize” what?
@christocracy I am sorry if I confused you. What I meant was if by any chance this library could be optimised or bypass the health motion related APIs.
Did you read this?
I did this
See API docs Config.disableMotionActivityUpdates
. Removing the permission from you AndroidManifest only prevents the motion API from operating in the background. It doesn't prevent it operating in the foreground.
This issue is stale because it has been open for 30 days with no activity.