We detected that your app contains at least one feature that requests access to location in the background #1362
-
My app was taken down from Google Play Store due
In other words Google is saying that I declared my app to only use location while app is in foreground but the app is requesting location while the app is int the background. By background in this case mean when user switch away from the app. With this post I would like to get feedback from the community. I am quite sure that there are many apps that does not use location in the background and still complaint with Google Policy. Things I tried
Why is this so hard to solve?
ObservationsGPS icon stays on when switching away from appOne of my phones(Huawer Y6 PRO 2019) shows GPS icon in status bar when GPS is in used. This GPS icon appears when app start to use location but stays on even when switching away from the app. The icon stays on until I kill the app. I experiment a bit and found that I can change renderMode from native to normal. In normal mode the GPS icon disappear when switching away from app. So it seems that there is an issue in logic when app is paused. <MapboxGL.UserLocation renderMode="normal" /> I created an issue for this as well with more info. https://github.com/react-native-mapbox-gl/maps/issues/1363 Minimal testIt is quite timeconsuming to know whether build comply with Google Policy. Every time I need to submit a new build to Google Play and wait several hours and see whether submitted bundle is affected. Here are so far my findings. No map (OK)import { Text } from 'native-base'
import { AppRegistry } from 'react-native'
import { hide } from 'react-native-bootsplash'
const App = () => <Text>Here comes app</Text>
hide()
AppRegistry.registerComponent('xxx', () => App) Map only (REJECTED)import React from 'react'
import { AppRegistry } from 'react-native'
import { hide } from 'react-native-bootsplash'
import { mapboxApiKey } from './constants'
import MapboxGL from '@react-native-mapbox-gl/maps'
hide()
MapboxGL.setAccessToken(mapboxApiKey)
const App = () => (
<MapboxGL.MapView
style={{
flex: 1,
}}
/>
)
AppRegistry.registerComponent('xxx', () => App)
export default App Ask for permissions before rendering map (REJECTED)import React, { useEffect, useState } from 'react'
import { AppRegistry, Text } from 'react-native'
import { hide } from 'react-native-bootsplash'
import { mapboxApiKey } from './constants'
import MapboxGL from '@react-native-mapbox-gl/maps'
hide()
MapboxGL.setAccessToken(mapboxApiKey)
const style = {
flex: 1,
}
const App = () => {
const [permission, setPermission] = useState(false)
const [isRequesting, setIsRequesting] = useState(true)
useEffect(() => {
MapboxGL.requestAndroidLocationPermissions().then((a) => {
setPermission(a)
setIsRequesting(false)
})
}, [])
if (isRequesting) {
return null
}
return (
<>
{!permission && (
<Text style={{ paddingTop: 100 }}>
You need to accept location permissions in order to use this
applications.
</Text>
)}
{permission && <MapboxGL.MapView style={style} />}
</>
)
}
AppRegistry.registerComponent('xxx', () => App)
export default App |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After a week of struggle my app is back in the Google Play Store. Here are things that I have done and not have done.
SummaryIt seems that Google has a bug when it evaluates whether app is using location in the background. To me it sounds that it checks internal,alpha and beta channels and incorrectly mark production builds as the issue. SolutionMake sure that you do not use location while your app is in the background. Remove ACCESS_BACKGROUND_LOCATION permission from AndroidManifest.xml. 📍Replace all your old apk and bundles in old internal, alpha, beta channels with newer build of your app. |
Beta Was this translation helpful? Give feedback.
After a week of struggle my app is back in the Google Play Store. Here are things that I have done and not have done.
S…