Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Permission.always.status returns permanentlyDenied even when can be requested #1145

Open
3 of 5 tasks
Smibser opened this issue Sep 7, 2023 · 9 comments
Open
3 of 5 tasks
Labels
P2 Important issues not at the top of the work list. platform: ios Issue is related to the iOS platform type: bug Something isn't working

Comments

@Smibser
Copy link

Smibser commented Sep 7, 2023

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

  1. request locationWhileInUse
  2. Choose 'Allow While Using App' on the ios device
  3. get status from location always permission

I already mentioned this issue here #1128. But since it's closed I decided to open another one. Maybe I am missing something again

Expected results

the permission status of the always location should be denied since it never was requested but can be requested

Actual results

the permission status is permantelyDenied. And therefore I have no way to check if I can request always permission or not

Code sample

Code sample
    final locationWhenInUseStatus = await Permission.locationWhenInUse.request();
    if (locationWhenInUseStatus.isPermantlyDenied) {
      print("Can't request always permission");
    } else {
      var locationAlwaysStatus = await Permission.locationAlways.request();
      // is never reached since 'Allow Only Once' and 'Allow While Using App' both return permantlyDenied
    }

Screenshots or video

No response

Version

10.2.0

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E772610a darwin-arm64, locale en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
[✓] VS Code (version 1.81.1)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

• No issues found!
@JeroenWeener
Copy link
Contributor

Hi @Smibser thank you for opening a new issue.

I did some investigation and this does indeed look like a bug which we should investigate.

Recording of the bug in action:
https://github.com/Baseflow/flutter-permission-handler/assets/9049645/a5622730-fbe8-4261-a934-a2fc8d8cf439

@JeroenWeener JeroenWeener added platform: ios Issue is related to the iOS platform type: bug Something isn't working P2 Important issues not at the top of the work list. labels Sep 7, 2023
@jeffscaturro-aka
Copy link

jeffscaturro-aka commented Sep 13, 2023

I came across something that may be related to this bug as well, around locationAlways (on iOS). It seems that await Permission.locationAlways.request(); doesn't actually wait for the user's response, and returns right away (as the ask dialog is presented to the user, not as the user responds to the dialog).

I logged a separate issue over here: #1152.

@MendleM
Copy link

MendleM commented Oct 30, 2023

I'm experiencing this too but for Permission.storage.request()

@fx7512
Copy link

fx7512 commented Jan 30, 2024

permission_handler: ^11.2.0

I encountered the same problem when using PermissionStatus permissionStatus = await Permission.photosAddOnly.request();

Is there any solution?

@Justincyz
Copy link

same issue on Permission.bluetooth

@merliandrea
Copy link

Same problem with Permission.photosAddOnly.request()

@nayanAubie
Copy link

@Smibser The same issue I am facing but in a different way.

  • Grant both permissions While using the app & Always Allow
  • Then change the permission by Settings app from Always to Ask Next Time or When I Share
  • After that, I can see a permission pop-up of While using the app but not for Always allow

@FFelipeWNeo
Copy link

Same problem with Permission.photos.request(), too.
Has anyone found a solution?

@mateendev3
Copy link

Actually for iOS if you are using PermissionHandler for permission handling. You need to specify the permissions in the info.plist file as well as in podFile.

Here is an example of podFile
`post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)

target.build_configurations.each do |config|
  # You can remove unused permissions here
  # for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
  # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
  config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',

    ## dart: PermissionGroup.calendar
    'PERMISSION_EVENTS=1',
    
    ## dart: PermissionGroup.calendarFullAccess
    'PERMISSION_EVENTS_FULL_ACCESS=1',

    ## dart: PermissionGroup.reminders
    'PERMISSION_REMINDERS=1',

    ## dart: PermissionGroup.contacts
    'PERMISSION_CONTACTS=1',

    ## dart: PermissionGroup.camera
    'PERMISSION_CAMERA=1',

    ## dart: PermissionGroup.microphone
    'PERMISSION_MICROPHONE=1',

    ## dart: PermissionGroup.speech
    'PERMISSION_SPEECH_RECOGNIZER=1',

    ## dart: PermissionGroup.photos
    'PERMISSION_PHOTOS=1',

    ## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
    ## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
    ## macro.
    ##
    ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
    'PERMISSION_LOCATION=1',
    'PERMISSION_LOCATION_WHENINUSE=0',

    ## dart: PermissionGroup.notification
    'PERMISSION_NOTIFICATIONS=1',

    ## dart: PermissionGroup.mediaLibrary
    'PERMISSION_MEDIA_LIBRARY=1',

    ## dart: PermissionGroup.sensors
    'PERMISSION_SENSORS=1',

    ## dart: PermissionGroup.bluetooth
    'PERMISSION_BLUETOOTH=1',

    ## dart: PermissionGroup.appTrackingTransparency
    'PERMISSION_APP_TRACKING_TRANSPARENCY=1',

    ## dart: PermissionGroup.criticalAlerts
    'PERMISSION_CRITICAL_ALERTS=1',

    ## dart: PermissionGroup.criticalAlerts
    'PERMISSION_ASSISTANT=1',
  ]

end

end
end`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list. platform: ios Issue is related to the iOS platform type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants