Flutter : Ask the user for permission until permission is granted
Asked Answered
A

2

6

Using https://pub.dev/packages/permission_handler to get permissions

but it won't ask the user again if user denied permission.

currently checked it on android (iOS device is not available)

Pls Help

Astro answered 25/2, 2022 at 9:29 Comment(2)
Android itself blocks it after 2 times refusing. I don't know if it's that you're experiencing, or that it already stops after 1 time asking.Prohibitionist
from here "Starting in Android 11, if the user taps Deny for a specific permission more than once during your app's lifetime of installation on a device, the user doesn't see the system permissions dialog if your app requests that permission again."Prohibitionist
P
10

If a user has already denied, only thing could be done is to redirect the user to application settings to enable needed permissions.

if (await Permission.speech.isPermanentlyDenied) {
  // The user opted to never again see the permission request dialog for this
  // app. The only way to change the permission's status now is to let the
  // user manually enable it in the system settings.
  openAppSettings();
}
Phares answered 25/2, 2022 at 14:23 Comment(2)
isPermanentlyDenied is returned only as result of request(). If just check for permission status - it says Denied.Scenarist
I don't see the location permission, or any permission for that matter, in the app settings within the iOS Settings app. Do we have to manually add that in root.plist or should it automatically show up as long as the permissions are listed within Info.plist within ios/Runner?Cornelie
B
0

As i understood you want to continuously ask user for permission if it is denied. You can implement something like this to continuously ask for the request unless you get something other than denied :

 Future<bool> askPermission() async{
    PermissionStatus status = await Permission.contacts.request();
    if(status.isDenied == true)
      {
        askPermission();
      }
    else
      {
        return true;
      }
  }

Call this type of method wherever you are requesting for the permission.

Blaine answered 25/2, 2022 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.