Skip to content
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

FOREGROUND_SERVICE_HEALTH #1953

Closed
irvinsingGitHub opened this issue Feb 22, 2024 · 39 comments
Closed

FOREGROUND_SERVICE_HEALTH #1953

irvinsingGitHub opened this issue Feb 22, 2024 · 39 comments
Labels

Comments

@irvinsingGitHub
Copy link

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
@christocracy
Copy link
Member

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.

@hisothreed
Copy link

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

@christocracy
Copy link
Member

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

@hisothreed
Copy link

hisothreed commented Mar 13, 2024

@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

@christocracy
Copy link
Member

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.

@TNAJanssen
Copy link

@hisothreed did you manage to get the permisson?

@irvinsingGitHub
Copy link
Author

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

@hiso3d
Copy link

hiso3d commented Mar 29, 2024

@TNAJanssen Yes it was accepted

@TNAJanssen
Copy link

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

@christocracy
Copy link
Member

christocracy commented Mar 29, 2024

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.

@jingp-ofload
Copy link

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

@christocracy
Copy link
Member

“Optimize” what?

@jp928
Copy link

jp928 commented Apr 23, 2024

use WorkManger instead? or stop using health motion apis?

@christocracy
Copy link
Member

You don’t understand what WorkManager is.

Did you not read the comment above yours?

@UnderTheMoonspell
Copy link

UnderTheMoonspell commented Apr 23, 2024

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)

@christocracy
Copy link
Member

Did you read this?

@UnderTheMoonspell
Copy link

@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

@christocracy
Copy link
Member

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

@UnderTheMoonspell
Copy link

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

@christocracy
Copy link
Member

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

@TNAJanssen
Copy link

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

@UnderTheMoonspell
Copy link

@TNAJanssen we got rejected even with that reason

@TNAJanssen
Copy link

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

@UnderTheMoonspell
Copy link

@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

@christocracy
Copy link
Member

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

Show us your video.

@jingp-ofload
Copy link

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

@christocracy
Copy link
Member

Did you read this?

@Glareous
Copy link

i did this...

but the app is still asking for health permissions..

@christocracy
Copy link
Member

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.

Copy link

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

@github-actions github-actions bot added the stale label May 26, 2024
Copy link

github-actions bot commented Jun 9, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed Jun 9, 2024
@SchneiderOr
Copy link

We're facing the same issue, it seems like this library using FOREGROUND_SERVICE, the suggested fix is not suitable for our needs since we need percise location tracking in bg.
We couldn't find the appropriate place in google play console to declare this permission, we do tried to add it to the AndroidManifest but no success, any suggestions here?

@christocracy
Copy link
Member

See the CHANGELOG

@SchneiderOr
Copy link

See the CHANGELOG

We're using the latest module version
we upgraded from 4.12.1 to 4.16.5 and the error started to appear, no migration or changes seemed to be needed to be taken care of when upgrading, and we still getting this android playsotre api error.

@christocracy
Copy link
Member

still getting this android playsotre api error.

What “error”, specifically?

@SchneiderOr
Copy link

[!] Google Api Error: Invalid request - You must let us know whether your app uses any Foreground Service permissions.
It dosent provide any additional details, but this error started since our upgrade from 4.12.1 > 4.16.5

@christocracy
Copy link
Member

Read my blog, log in to Play Store Console and provide the required information as documented in my blog.

@SchneiderOr
Copy link

SchneiderOr commented Jul 30, 2024

Read my blog, log in to Play Store Console and provide the required information as documented in my blog.

Thanks, i was finally been able to declare the Foreground permissions in play store and resolved my issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants