簡體   English   中英

權限總是返回 never_ask_again

[英]Permission always returns never_ask_again

復制步驟:

react-native init project

<add code below to the project(App.js component)>

react-native run-android

我在文本組件的onPress中調用了該函數。

即使對於新的應用程序運行,權限請求也始終返回 never_ask_again。

async requestPermissions() {
// android 6.0 +
if (Platform.OS === 'android' && Platform.Version >= 23) {
  try {
    const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
      'title': 'Let the access location',
      'message': 'locate you.'
    });
    console.log('granted: ', granted);
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
      Alert.alert("Granted access", [{ text: "ok" }])
    } else {
      Alert.alert(
        "can't access to GPS title",
        "returned " + granted,
        [
          { text: "ok" }
        ]
      );
    }
  } catch (err) {
  }
}
}

即使從設置中啟用了權限,仍然返回 never_ask_again。

React Native Version: 0.55.2

React Version: 16.3.1

在 app/build.gradle 中

targetSdkVersion 23

謝謝

我錯過的一件事是在AppManifest.xml添加<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM