Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.05k stars 860 forks source link

[Bug]: Permission status can't distinguish denied vs permanently denied when Android "Ask every time" option is used #1206

Open jjoelson opened 1 year ago

jjoelson commented 1 year ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

This issue is a follow-up to my comment in https://github.com/Baseflow/flutter-permission-handler/pull/1130.

  1. Request permission over and over (e.g. with Permission.camera.request()) and deny each time until the result is "permanently denied".
  2. Open Android system settings and set the permission in question for the app to "Ask every time".
  3. Switch back to the app and check the permission status (e.g. with Permission.camera.status).

Expected results

The status is PermissionStatus.denied.

Actual results

The status is PermissionStatus.permanentlyDenied.

Code sample

Code sample ```dart import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State { PermissionStatus? _currentStatus; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(), body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ Text('Permission Status: $_currentStatus'), TextButton( onPressed: _checkStatus, child: const Text('Check Permission Status'), ), TextButton( onPressed: _requestStatus, child: const Text('Request Permission'), ), ], ), ), ), ); } void _checkStatus() async { final status = await Permission.camera.status; setState(() { _currentStatus = status; }); } void _requestStatus() async { final status = await Permission.camera.request(); setState(() { _currentStatus = status; }); } } ```

Screenshots or video

No response

Version

11.0.1

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.13.9, on macOS 13.6 22G120 darwin-arm64, locale en-US) • Flutter version 3.13.9 on channel stable at /Users/jonathanjoelson/repos/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision d211f42860 (5 days ago), 2023-10-25 13:42:25 -0700 • Engine revision 0545f8705d • Dart version 3.1.5 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/jonathanjoelson/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = /Users/jonathanjoelson/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14A400 • CocoaPods version 1.12.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) [✓] VS Code (version 1.83.0) • VS Code at /Users/jonathanjoelson/Desktop/Visual Studio Code.app/Contents • Flutter extension version 3.74.0 [✓] Connected device (4 available) • Pixel 4a (mobile) • 0B201JEC221560 • android-arm64 • Android 13 (API 33) • iPhone 13 (mobile) • 120E063D-E34D-44F8-A6C3-7CB0146B4B76 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 13.6 22G120 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 111.0.5563.64 [✓] Network resources • All expected network resources are available. • No issues found! ```
JeroenWeener commented 1 year ago

Thanks for bringing this up @jjoelson. I was able to reproduce this issue.

MarwanAdel1 commented 7 months ago

is there a work around for this issue?

JeroenWeener commented 7 months ago

As far as I know, no one has picked up this issue as of yet. If you feel like you could contribute, feel free to open a PR. The Baseflow team would probably be happy to assist you. @TimHoogstrate @mvanbeusekom.

FerrandTian commented 2 weeks ago

I have this issue too.