react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

FOREGROUND_SERVICE_HEALTH

Open irvinsingGitHub opened this issue 1 year ago • 30 comments

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

irvinsingGitHub avatar Feb 22 '24 12:02 irvinsingGitHub

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.

christocracy avatar Feb 22 '24 14:02 christocracy

@irvinsingGitHub Mine is also getting rejected, did you manage to solve it?

hisothreed avatar Mar 13 '24 16:03 hisothreed

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 avatar Mar 13 '24 16:03 christocracy

@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

hisothreed avatar Mar 13 '24 16:03 hisothreed

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.

christocracy avatar Mar 13 '24 16:03 christocracy

@hisothreed did you manage to get the permisson?

TNAJanssen avatar Mar 28 '24 13:03 TNAJanssen

@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.

irvinsingGitHub avatar Mar 29 '24 00:03 irvinsingGitHub

@TNAJanssen Yes it was accepted

hiso3d avatar Mar 29 '24 00:03 hiso3d

@hiso3d what did you end up using as the reason and the notifing of the user?

TNAJanssen avatar Mar 29 '24 14:03 TNAJanssen

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 avatar Mar 29 '24 15:03 christocracy

@christocracy Is there way to optimise this. I've got reject from google. Screenshot 2024-04-23 at 9 22 30 PM

jingp-ofload avatar Apr 23 '24 11:04 jingp-ofload

“Optimize” what?

christocracy avatar Apr 23 '24 11:04 christocracy

use WorkManger instead? or stop using health motion apis?

jp928 avatar Apr 23 '24 11:04 jp928

You don’t understand what WorkManager is.

Did you not read the comment above yours?

christocracy avatar Apr 23 '24 11:04 christocracy

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)

UnderTheMoonspell avatar Apr 23 '24 12:04 UnderTheMoonspell

Did you read this?

christocracy avatar Apr 23 '24 12:04 christocracy

@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

UnderTheMoonspell avatar Apr 23 '24 12:04 UnderTheMoonspell

Then it’s up to you to follow the instructions requested by the Play Store and prove to them why you need that permission.

christocracy avatar Apr 23 '24 12:04 christocracy

Yes to be honest i just replied to increase awareness as we're already doing that :)

UnderTheMoonspell avatar Apr 23 '24 12:04 UnderTheMoonspell

I’m soon going to completely remove this permission from the plug-in, turning it from an opt-out to an opt-in.

christocracy avatar Apr 23 '24 12:04 christocracy

We got accepted with the reason @christocracy gave us. So when describing it correctly they do allow it

TNAJanssen avatar Apr 23 '24 12:04 TNAJanssen

@TNAJanssen we got rejected even with that reason

UnderTheMoonspell avatar Apr 23 '24 12:04 UnderTheMoonspell

For us what helped was a permission screen in between asking for permission where we state why we need the health permission.

TNAJanssen avatar Apr 23 '24 12:04 TNAJanssen

@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

UnderTheMoonspell avatar Apr 23 '24 12:04 UnderTheMoonspell

we have the "same" screen, we uploaded a video sending a user to that screen

Show us your video.

christocracy avatar Apr 23 '24 12:04 christocracy

“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.

jingp-ofload avatar Apr 23 '24 23:04 jingp-ofload

Did you read this?

christocracy avatar Apr 23 '24 23:04 christocracy

i did this...

but the app is still asking for health permissions..

Glareous avatar Apr 25 '24 16:04 Glareous

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.

christocracy avatar Apr 25 '24 16:04 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 26 '24 01:05 github-actions[bot]