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.02k stars 838 forks source link

[Bug]: iOS: Permission.criticalAlerts.request() does always return PermissionStatus.granted on the first request #1284

Open pfraunlob opened 7 months ago

pfraunlob commented 7 months ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

  1. request critical alert permission on iOS with await Permission.criticalAlerts.request(); for the first time
  2. A iOS dialog is shown. Press "do not allow"

A workaround we currently use is to return Permission.criticalAlerts.status; after the request to get the correct status.

Expected results

returns PermissionStatus.permanentlyDenied

Actual results

returns PermissionStatus.granted

Code sample

Code sample ```dart Future requestCriticalAlertPermission() async { final permissionStatus = await Permission.criticalAlerts.request(); // This will return PermissionStatus.granted on the first request even if the user has denied the permission. return permissionStatus; } ```

Screenshots or video

No response

Version

11.2.1

Flutter Doctor output

/Users/pfraunlob/dev/source/flutter/bin/flutter doctor --verbose [✓] Flutter (Channel stable, 3.16.7, on macOS 14.3 23D56 darwin-x64, locale de-AT) • Flutter version 3.16.7 on channel stable at /Users/pfraunlob/dev/source/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ef1af02aea (vor 5 Wochen), 2024-01-11 15:19:26 -0600 • Engine revision 4a585b7929 • Dart version 3.2.4 • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at /Users/pfraunlob/Library/Android/sdk • Platform android-34, build-tools 33.0.1 • ANDROID_HOME = /Users/pfraunlob/Library/Android/sdk • Java binary at: /Users/pfraunlob/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.11005911/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.14.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3) • Android Studio at /Users/pfraunlob/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.11005911/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 17.0.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 2022.3) • Android Studio at /Users/pfraunlob/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10811636/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 17.0.6+0-17.0.6b829.9-10027231)

[✓] Connected device (3 available) • iPhone 15 (mobile) • DEBA783D-8EDC-41B2-A2B9-9262A9F4A5D6 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-x64 • macOS 14.3 23D56 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.160

[✓] Network resources • All expected network resources are available.

• No issues found! Process finished with exit code 0

LucyJeong commented 6 months ago

I've encountered the same critical issue as well. On the iPhone, even when the permission for the first notification request is granted, the return value indicates it was denied. This has resulted in a significant loss of user trust.

first call is PermissionStatus.permanentlyDenied. second call is granted.

kkh975 commented 3 months ago

me too. Does anyone know how to solve it?

Hoai-Phong commented 3 weeks ago

@kkh975 @LucyJeong me too

When I have granted permission on the app, why does it still show as permanentlyDenied? Is there any way to fix it?

image