QuisApp / flutter_contacts

MIT License
88 stars 143 forks source link

Problem with "requestPermission" return value on Android. #177

Open eduardobandeiramg opened 1 month ago

eduardobandeiramg commented 1 month ago

On Android, once the user allows the reading of contacts for the first time, the OS stops asking again on further occasions for a while. However, when this permission is already given to the app, the requestPermission function returns the boolean "false" instead of "true" (probably because that's the standard value and the function is not being called). It's only happening on Android, on IOS it's fine.

B-Fabrice commented 1 month ago

Hello @eduardobandeiramg,

I encountered a similar issue on Android, which required me to check the platform before proceeding. I utilized the permission_handler package to request the necessary permissions and verify their status. Below is a sample of the code I implemented:

const p = Permission.contacts;
await p.request();
if (Platform.isAndroid && await p.isPermanentlyDenied) {
    // Handle the case where the permission is permanently denied
}

This approach resolved the issue for me. I hope it helps you as well!