Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission always returns never_ask_again

Steps to replicate:

react-native init project

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

react-native run-android

I called the function in onPress of a text component.

The permission request always returns never_ask_again even for the fresh app run.

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) {
  }
}
}

Even when the permissions is enabled from settings, still the never_ask_again is returned.

React Native Version: 0.55.2

React Version: 16.3.1

in app/build.gradle

targetSdkVersion 23

Thanks

like image 213
snjmhj Avatar asked Apr 11 '18 09:04

snjmhj


1 Answers

One thing I missed was to add <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> in AppManifest.xml

like image 173
snjmhj Avatar answered Sep 29 '22 10:09

snjmhj