Does not request permission on android when calling requestPermission
When using requestPermission ReactMethod on android ContactsManager react module, it only checks if permission for READ_CONTACTS is granted. It needs to prompt user for permission for API 23+
@ReactMethod
public void requestPermission(Callback callback) {
callback.invoke(null, isPermissionGranted());
}
You need to specifically handle the Android case with PermissionsAndroid.request like so:
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
title: 'Permission to Read Contacts',
message: 'MyContacts needs permission to read contacts'
},
PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS,
{
title: 'Permission to Write Contacts',
message: 'MyContacts needs permission to write contacts'
},
PermissionsAndroid.PERMISSIONS.READ_PROFILE,
{
title: 'Permission to Read Profile',
message: 'MyContacts needs permission to read profile'
}
);
This worked for me.
@nfplay did you remove the uses-permission tags from your AndroidManifest.xml to get this to work?
<!-- FOR CONTACTS LIBRARY -->
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
I removed them but in my JS code when I use PermissionsAndroid.request to get READ_CONTACTS and READ_PROFILE permissions I keep getting returned never_ask_again.
Also READ_PROFILE does not exist in PermissionsAndroid.PERMISSIONS unfortunately as of RN 0.48