flutter-permission-handler
flutter-permission-handler copied to clipboard
ios permission has been denied before, and not show prompt again
I have check location permission every open application. if permission denied so application will close. but on ios after I denied the permission and reopen application, the prompt permission is not showing again. but not in android. how to always check permission at startup application even though permission has been denied before?
if (await Permission.location.request().isGranted) {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => const MyBottomNavigation()),
(Route<dynamic> route) => false,
);
} else {
const snackBar = SnackBar(content: Text("Permission Denied"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Timer(const Duration(seconds: 1), () async {
exit(0);
});
}
Hi @eggyot, I tested this behavior to be sure on Android, and indeed the permission dialog does show up everytime you open the app and ask for the permission. I think the reason for this behavior is because on Android the permission status will be PermissionStatus.denied everytime you deny the permission. On iOS however, I think it will be PermissionStatus.permanentlyDenied which means you have to manually enable it for the app in the settings.
I can be wrong since I do not have an Apple device nearby to test it for you, but I'm most certain that that is the problem. Is it possible that you can check this, if the permission indeed is permanentlyDenied? You can do this so by adding one extra print line in your example code to see the results. in the else statement you can do this:
else {
const snackBar = SnackBar(content: Text("Permission Denied"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
print(await Permission.location.status);
Timer(const Duration(seconds: 1), () async {
exit(0);
});
Let me know if it worked so we can close this issue, elsewise I would be happy to hear more if it was not the problem!
Edit: Maybe this thread can give you some more clearance, and the answer underneath that too.
Im not sure if this is what his asking but on IOS with the notification permission, it shows its Denied, and it will not show prompt with await Permission.notification.request().isGranted
I'm experiencing a similar issue on Android. These are the steps I follow:
- Ask for phone permission
- Select deny on dialog
- Ask again for phone permission
- Select deny on dialog
- Try to ask again for phone permission Dialog is not coming up anymore no matter how many times I request from now on. I tried killing the app and then retry but no luck. PermissionStatus is not permanentlyDenied, it is denied. Only solution is to delete the app and reinstall.
After two tries the OS blocks additional tries on Android. I've tested this and it works as expected. So, after two don't allows it gets a status of permanentlyDenied (I think this is from Android > 10). So I'll close this issue. Feel free to reopen the issue when you have some additional information or additional questions. Preferably open a new issue with some detailed steps to reproduce and the output of flutter doctor -v.
Kind regards,
My issue is after permanently denying the permission I don't see the toggle in iOS Settings > my app.