React native 已授予react本机位置权限
Im使用react native cli,并使用后台地理定位。(目前我只使用android) 我试图将该应用发布到play store,但他们说我必须添加使用位置服务的权限 我做了一些搜索,但没有找到适合我的答案: 我试过:React native 已授予react本机位置权限,react-native,android-permissions,React Native,Android Permissions,Im使用react native cli,并使用后台地理定位。(目前我只使用android) 我试图将该应用发布到play store,但他们说我必须添加使用位置服务的权限 我做了一些搜索,但没有找到适合我的答案: 我试过: async requestLocationPermission(){ try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSI
async requestLocationPermission(){
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Example App',
'message': 'Example App access to your location '
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the location")
alert("You can use the location");
} else {
console.log("location permission denied")
alert("Location permission denied");
}
} catch (err) {
console.warn(err)
}
}
async componentDidMount() {
await this.requestLocationPermission()
但它直接指向“你可以使用这个位置”
在我移动到背景地理位置之前,它确实需要获得许可,但现在我甚至没有注意到这一点,直到被google play拒绝
我为此做了一些研究,但没有成功
对不起,我的英语,如果你能帮我,我真的很感激。
我需要位置权限对话框
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <uses-library android:name="org.apache.http.legacy" android:required="false"/> -->
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="..."/>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
无论您向用户请求哪种权限,都必须将它们添加到AndroidManifest.xml
文件中。你可以找到更多的信息谢谢你的回答,我已经在舱单上了