Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.

Overview

pub package Build status style: effective dart

On most operating systems, permissions aren't just granted to apps at install time. Rather, developers have to ask the user for permissions while the app is running.

This plugin provides a cross-platform (iOS, Android) API to request permissions and check their status. You can also open the device's app settings so users can grant a permission.
On Android, you can show a rationale for requesting a permission.

Setup

While the permissions are being requested during runtime, you'll still need to tell the OS which permissions your app might potentially use. That requires adding permission configuration to Android- and iOS-specific files.

Android

Upgrade pre 1.12 Android projects

Since version 4.4.0 this plugin is implemented using the Flutter 1.12 Android plugin APIs. Unfortunately this means App developers also need to migrate their Apps to support the new Android infrastructure. You can do so by following the Upgrading pre 1.12 Android projects migration guide. Failing to do so might result in unexpected behaviour. Most common known error is the permission_handler not returning after calling the .request() method on a permission.

AndroidX

As of version 3.1.0 the permission_handler plugin switched to the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found here.

The TL;DR version is:

  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 28:
android {
  compileSdkVersion 28
  ...
}
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).

Add permissions to your AndroidManifest.xml file. There's a debug, main and profile version which are chosen depending on how you start your app. In general, it's sufficient to add permission only to the main version. Here's an example AndroidManifest.xml with a complete list of all possible permissions.

iOS

Add permission to your Info.plist file. Here's an example Info.plist with a complete list of all possible permissions.

IMPORTANT: You will have to include all permission options when you want to submit your App. This is because the permission_handler plugin touches all different SDKs and because the static code analyser (run by Apple upon App submission) detects this and will assert if it cannot find a matching permission option in the Info.plist. More information about this can be found here.

The permission_handler plugin use macros to control whether a permission is supported.

You can remove permissions you don't use:

  1. Add the following to your Podfile file:
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          ... # Here are some configurations automatically generated by flutter
    
          # You can remove unused permissions here
          # for more infomation: https://github.com/BaseflowIT/flutter-permission-handler/blob/develop/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=0',
    
            ## dart: PermissionGroup.reminders
            # 'PERMISSION_REMINDERS=0',
    
            ## dart: PermissionGroup.contacts
            # 'PERMISSION_CONTACTS=0',
    
            ## dart: PermissionGroup.camera
            # 'PERMISSION_CAMERA=0',
    
            ## dart: PermissionGroup.microphone
            # 'PERMISSION_MICROPHONE=0',
    
            ## dart: PermissionGroup.speech
            # 'PERMISSION_SPEECH_RECOGNIZER=0',
    
            ## dart: PermissionGroup.photos
            # 'PERMISSION_PHOTOS=0',
    
            ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
            # 'PERMISSION_LOCATION=0',
           
            ## dart: PermissionGroup.notification
            # 'PERMISSION_NOTIFICATIONS=0',
    
            ## dart: PermissionGroup.mediaLibrary
            # 'PERMISSION_MEDIA_LIBRARY=0',
    
            ## dart: PermissionGroup.sensors
            # 'PERMISSION_SENSORS=0'
            
            ## dart: PermissionGroup.bluetooth
            # 'PERMISSION_BLUETOOTH=0'
          ]
    
        end
      end
    end
  2. Remove the # character in front of the permission you do not want to use. For example if you don't need access to the calendar make sure the code looks like this:
            ## dart: PermissionGroup.calendar
            'PERMISSION_EVENTS=0',
  3. Delete the corresponding permission description in Info.plist e.g. when you don't need camera permission, just delete 'NSCameraUsageDescription' The following lists the relationship between Permission and The key of Info.plist:
    Permission Info.plist Macro
    PermissionGroup.calendar NSCalendarsUsageDescription PERMISSION_EVENTS
    PermissionGroup.reminders NSRemindersUsageDescription PERMISSION_REMINDERS
    PermissionGroup.contacts NSContactsUsageDescription PERMISSION_CONTACTS
    PermissionGroup.camera NSCameraUsageDescription PERMISSION_CAMERA
    PermissionGroup.microphone NSMicrophoneUsageDescription PERMISSION_MICROPHONE
    PermissionGroup.speech NSSpeechRecognitionUsageDescription PERMISSION_SPEECH_RECOGNIZER
    PermissionGroup.photos NSPhotoLibraryUsageDescription PERMISSION_PHOTOS
    PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription PERMISSION_LOCATION
    PermissionGroup.notification PermissionGroupNotification PERMISSION_NOTIFICATIONS
    PermissionGroup.mediaLibrary NSAppleMusicUsageDescription, kTCCServiceMediaLibrary PERMISSION_MEDIA_LIBRARY
    PermissionGroup.sensors NSMotionUsageDescription PERMISSION_SENSORS
    PermissionGroup.bluetooth NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription PERMISSION_BLUETOOTH
  4. Clean & Rebuild

How to use

There are a number of Permissions. You can get a Permission's status, which is either granted, denied, restricted or permanentlyDenied.

var status = await Permission.camera.status;
if (status.denied) {
  // We didn't ask for permission yet or the permission has been denied before but not permanently.
}

// You can can also directly ask the permission about its status.
if (await Permission.location.isRestricted) {
  // The OS restricts access, for example because of parental controls.
}

Call request() on a Permission to request it. If it has already been granted before, nothing happens.
request() returns the new status of the Permission.

if (await Permission.contacts.request().isGranted) {
  // Either the permission was already granted before or the user just granted it.
}

// You can request multiple permissions at once.
Map<Permission, PermissionStatus> statuses = await [
  Permission.location,
  Permission.storage,
].request();
print(statuses[Permission.location]);

Some permissions, for example location or acceleration sensor permissions, have an associated service, which can be enabled or disabled.

if (await Permission.locationWhenInUse.serviceStatus.isEnabled) {
  // Use location.
}

You can also open the app settings:

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();
}

On Android, you can show a rationale for using a permission:

bool isShown = await Permission.contacts.shouldShowRequestRationale;

Issues

Please file any issues, bugs or feature request as an issue on our GitHub page. Commercial support is available if you need help with integration with your app or services. You can contact us at [email protected].

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This Permission handler plugin for Flutter is developed by Baseflow. You can contact us at [email protected]

Issues
  • Apple rejects all binaries built using this package, unless ALL permissions have purposes/reasons added in the .plist, even if the app is not using most of them...

    Apple rejects all binaries built using this package, unless ALL permissions have purposes/reasons added in the .plist, even if the app is not using most of them...

    Apple now rejects all apps, the error is as follows:

    Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSContactsUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

    Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSCalendarsUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

    Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSAppleMusicUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

    Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSMotionUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

    Missing Purpose String in Info.plist File - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSSpeechRecognitionUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data will be required to include a purpose string.If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

    opened by manuelgomes2 63
  • iOS Build fails with multiple errors

    iOS Build fails with multiple errors

    ๐Ÿ› Bug Report

    With today's update to 5.1.0+2, all of our iOS builds are failing.

    Xcode's output:
    โ†ณ
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:40:81: error: use of undeclared identifier 'PHAccessLevelAddOnly'
                [PHPhotoLibrary requestAuthorizationForAccessLevel:(addOnlyAccessLevel)?PHAccessLevelAddOnly:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus authorizationStatus) {
                                                                                        ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:40:102: error: use of undeclared identifier 'PHAccessLevelReadWrite'
                [PHPhotoLibrary requestAuthorizationForAccessLevel:(addOnlyAccessLevel)?PHAccessLevelAddOnly:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus authorizationStatus) {
                                                                                                             ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:53:89: error: use of undeclared identifier 'PHAccessLevelAddOnly'
                status = [PHPhotoLibrary authorizationStatusForAccessLevel:(addOnlyAccessLevel)?PHAccessLevelAddOnly:PHAccessLevelReadWrite];
                                                                                                ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:53:110: error: use of undeclared identifier 'PHAccessLevelReadWrite'
                status = [PHPhotoLibrary authorizationStatusForAccessLevel:(addOnlyAccessLevel)?PHAccessLevelAddOnly:PHAccessLevelReadWrite];
                                                                                                                     ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:71:14: error: use of undeclared identifier 'PHAuthorizationStatusLimited'; did you mean 'PHAuthorizationStatusDenied'?
                case PHAuthorizationStatusLimited:
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     PHAuthorizationStatusDenied
        In module 'Photos' imported from /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.h:11:
        /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/System/Library/Frameworks/Photos.framework/Headers/PHPhotoLibrary.h:22:5: note: 'PHAuthorizationStatusDenied' declared here
            PHAuthorizationStatusDenied,            // User has explicitly denied this application access to photos data.
            ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:71:14: error: duplicate case value 'PHAuthorizationStatusDenied'
                case PHAuthorizationStatusLimited:
                     ^
        /Users/vagrant/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/ios/Classes/strategies/PhotoPermissionStrategy.m:67:14: note: previous case defined here
                case PHAuthorizationStatusDenied:
                     ^
        6 errors generated.
    

    Expected behavior

    App should build

    Reproduction steps

    Note that we are using Bitrise CI/CD for consistent builds. This error occurs in every build we attempt.

    Configuration

    This is a pretty large app, so lots of variables here, not sure what is needed - let me know.

    pubspec.yaml is looking for: permission_handler: ^5.0.0+hotfix.6

    Podfile includes:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
            '$(inherited)',
            ## dart: PermissionGroup.calendar
            'PERMISSION_EVENTS=0',
            ## dart: PermissionGroup.reminders
            'PERMISSION_REMINDERS=0',
            ## dart: PermissionGroup.contacts
            'PERMISSION_CONTACTS=0',
            ## dart: PermissionGroup.microphone
            'PERMISSION_MICROPHONE=0',
            ## dart: PermissionGroup.speech
            'PERMISSION_SPEECH_RECOGNIZER=0',
            ## dart: PermissionGroup.mediaLibrary
            'PERMISSION_MEDIA_LIBRARY=0',
            ## dart: PermissionGroup.sensors
            'PERMISSION_SENSORS=0'
          ]
        end
        flutter_additional_ios_build_settings(target)
      end
    end
    

    Version: permission_handler: 5.1.0+2 flutter: 1.22.4

    Platform:

    • [x] :iphone: iOS
    • [ ] :robot: Android
    opened by bryantgtx 41
  • requestPermission does not return result

    requestPermission does not return result

    ๐Ÿ”™ Regression

    List permissions_group = [PermissionGroup.contacts, PermissionGroup.storage];

    Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions(permissions_group);

    print(permissions)

    Hi, I tried to run the code above. Unfortunately, I cannot get the result after granting the permission from the dialog. Any suggestion?

    opened by NeroJz 30
  • Make API more intuitive

    Make API more intuitive

    First of all: Thanks for this great package! ๐Ÿ˜Š It's widely adopted for good reasons and I want to congratulate you on that.

    I understand how the API of this package got designed but Dart's introduction of extension methods makes it possible to design a much tighter, more readable API. Here are just some of my ideas:

    Enums: I think the PermissionStatus and ServiceStatus should be enums so that users can switch over the result. Values and other methods can still be defined using extension methods.

    PermissionHandler: I know this is what gives the package its name, but I'm not sure a PermissionHandler is needed at all. Currently, it mainly provides a namespace for all the functions of this package. But they could be defined just as well on the PermissionGroups themselves, which seems much more intuitive to me. status could be a getter, because it doesn't perform an action that the developer or user perceives. Developers still know that some work is involved, because it returns a Future. Also, most of the time you only want to request a single permission, so it makes sense to also provide a method for that.

    current | proposed --- | --- await PermissionHandler() .checkPermissionStatus(PermissionGroup.camera) | await PermissionGroup.camera.status (await PermissionHandler() .requestPermissions([PermissionGroup.camera]))[PermissionGroup.camera] | await PermissionGroup.camera.request() PermissionHandler() .requestPermissions([PermissionGroup.camera, PermissionGroup.storage])) | await [PermissionGroup.camera, PermissionGroup.storage].request()

    Intuitive getters: Sure, users can always check someStatus == PermissionStatus.granted, but someStatus.isGranted seems more intuitive, allowing for (await PermissionGroup.camera.status).isGranted. These getters could not only get implemented on PermissionStatus, but also on Future<PermissionStatus>, allowing even terser syntax: await PermissionGroup.camera.checkStatus().isGranted. To make the API more declarative, maybe these getters could also get directly implemented on PermissionGroups as syntactic sugar for implicitly calling the check() function: await PermissionGroup.camera.isGranted

    Support common patterns: Very often, permissions are checked and if they are denied, a request is made. That could be supported using some requestIfDenied method, that returns the status if the status is not PermissionStatus.denied and otherwise requests the permission from the user and then returns the new status: PermissionGroup.camera.requestIfDenied()

    PermissionGroups? I understand that some of the permissions resemble multiple OS-level permissions, but I think that's an implementation detail that most developers using this API don't really care about. Maybe, PermissionGroup could get renamed to Permission?

    Putting it all together Most of this was trivial syntactic sugar, but putting it all together, it makes for much more terse code. What before looked like this:

    var handler = PermissionHandler();
    var permission = await handler.checkPermissionStatus(PermissionGroup.storage);
    if (permission != PermissionStatus.granted) {
      var permissions = await handler.requestPermissions([PermissionGroup.storage]);
      if (permissions[PermissionGroup.storage] != PermissionStatus.granted) {
        // Do stuff.
      }
    }
    

    could now be as easy as this:

    if (await Permission.storage.requestIfDenied().isGranted) {
      // Do stuff.
    }
    

    Of course, these are breaking changes to the api and require a major version update to 5.0.0. I do think though that the simplicity of that API would be worth it. What do you think about these changes? If you decide on redesigning the API, I'm happy to help to implement the changes.

    platform: android platform: ios status: in progress type: enhancement 
    opened by MarcelGarus 29
  • Android app crashes after permission request popup

    Android app crashes after permission request popup

    ๐Ÿ› Bug Report

    Android app crashes first time request permission when launching, on both deny and grant action . The app restarts, it works fine then.

    Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.location]);

    D/AndroidRuntime( 8448): Shutting down VM
    E/AndroidRuntime( 8448): FATAL EXCEPTION: main
    E/AndroidRuntime( 8448): Process: com.berkey.berkey, PID: 8448
    E/AndroidRuntime( 8448): java.lang.RuntimeException: Failure delivering result ResultInfo{[email protected]:requestPermissions:, request=25, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.berkey.berkey/com.berkey.berkey.MainActivity}: java.lang.IllegalStateException: Reply already submitted
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4268)
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:4312)
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread.-wrap19(Unknown Source:0)
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1644)
    E/AndroidRuntime( 8448): 	at android.os.Handler.dispatchMessage(Handler.java:106)
    E/AndroidRuntime( 8448): 	at android.os.Looper.loop(Looper.java:164)
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
    E/AndroidRuntime( 8448): 	at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime( 8448): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    E/AndroidRuntime( 8448): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    E/AndroidRuntime( 8448): Caused by: java.lang.IllegalStateException: Reply already submitted
    E/AndroidRuntime( 8448): 	at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174)
    E/AndroidRuntime( 8448): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:203)
    E/AndroidRuntime( 8448): 	at com.baseflow.permissionhandler.PermissionHandlerPlugin.processResult(PermissionHandlerPlugin.kt:316)
    E/AndroidRuntime( 8448): 	at com.baseflow.permissionhandler.PermissionHandlerPlugin.handlePermissionsRequest(PermissionHandlerPlugin.kt:308)
    E/AndroidRuntime( 8448): 	at com.baseflow.permissionhandler.PermissionHandlerPlugin.access$handlePermissionsRequest(PermissionHandlerPlugin.kt:28)
    E/AndroidRuntime( 8448): 	at com.baseflow.permissionhandler.PermissionHandlerPlugin$Companion$registerWith$1.onRequestPermissionsResult(PermissionHandlerPlugin.kt:46)
    E/AndroidRuntime( 8448): 	at io.flutter.app.FlutterPluginRegistry.onRequestPermissionsResult(FlutterPluginRegistry.java:191)
    E/AndroidRuntime( 8448): 	at io.flutter.app.FlutterActivityDelegate.onRequestPermissionsResult(FlutterActivityDelegate.java:125)
    E/AndroidRuntime( 8448): 	at io.flutter.app.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:133)
    E/AndroidRuntime( 8448): 	at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7429)
    E/AndroidRuntime( 8448): 	at android.app.Activity.dispatchActivityResult(Activity.java:7280)
    E/AndroidRuntime( 8448): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:4264)
    E/AndroidRuntime( 8448): 	... 9 more
    Lost connection to device.
    

    Version: 2.2.0

    Platform:

    • [ ] :iphone: iOS
    • [x ] :robot: Android
    opened by comeonbuddy 27
  • Android Camera permission: Permission.camera.status returns undetermined when it should be permanentlyDenied

    Android Camera permission: Permission.camera.status returns undetermined when it should be permanentlyDenied

    ๐Ÿ› Bug Report

    Permission.camera.status returns undetermined if called immediately after the user permanentlyDenies the access. In older android versions, keeps returning undetermined for longer whiles than in android 10 when the user clicks on permanentlyDenied option.

    Reproduction steps

    1. Request user for permission
    2. Permanently deny the permission from the user's end
    3. Ask for permission status

    Actual behavior

    The permission status is returned as undetermined once. Requesting the permission status again returns it as permanentlyDenied.

    Expected behaviour

    The permission status should be returned as permanentlyDenied.

    Configuration

    Version: ^5.0.0+hotfix.3

    [โœ“] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.5 19F101, locale en-IN)
     
    [โœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    [โœ“] Xcode - develop for iOS and macOS (Xcode 11.2.1)
    [โœ“] Android Studio (version 3.5)
    [โœ“] VS Code (version 1.46.1)
    [โœ“] Connected device (1 available)
    
    โ€ข No issues found!
    

    Platform:

    • [ ] :iphone: iOS
    • [x] :robot: Android
    platform: android type: bug 
    opened by viplavrawal 24
  • Unhandled Exception: MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)

    Unhandled Exception: MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)

    ๐Ÿ› Bug Report

    E/flutter (16782): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method requestPermissions on channel flutter.baseflow.com/permissions/methods)

    When I try to run

    Future _handleCameraAndMicPermission() async { // You can request multiple permissions at once. Map<Permission, PermissionStatus> statuses = await [ Permission.camera, Permission.microphone, ].request(); print(statuses[Permission.camera]); }

    Expected behavior

    There should be popup for camera and microphone permission

    Configuration

    Using permission_handler: ^5.0.0+hotfix.8 AndroidX enabled android.useAndroidX=true android.enableJetifier=true

    Platform:

    • [ ] :iphone: iOS
    • [x ] :robot: Android
    platform: android status: needs more info status: triage 
    opened by RizanPSTU 22
  • [BUG][iOS] Permission Popup not being displayed

    [BUG][iOS] Permission Popup not being displayed

    On iOS, on either a real or a simulated device, the iOS popup for accepting the permission is not being displayed. On Android everything is working right. On iOS, running the command await permission.request() returns PermissionStatus.undetermined without showing the popup.

    I've strictly followed the steps specified on pub.dev page, on my current project and on a new project created just for this. It use to work in a previous build I've made of the same code about 1 month ago (I don't remember which version of Flutter and PermissionHandler was using).

    My Flutter doctor output is:

    Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.6 ...)
    Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    Xcode - develop for iOS and macOS (Xcode 12.0)
    Android Studio (version 4.0)
    Connected device (1 available)
    
    No issues found!
    

    Anyone has any helpful info? I will gladly give any additional info :)!

    Thank you!

    opened by sajunt4 22
  • Unable to detect current Android Activity., null, null

    Unable to detect current Android Activity., null, null

    [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(PermissionHandler.PermissionManager, Unable to detect current Android Activity., null, null)

    platform: android 
    opened by Ronadlo7 22
  • Move to objc

    Move to objc

    Update on https://github.com/BaseflowIT/flutter-geolocator/issues/178

    opened by long1eu 22
  • [iOS] Location permission status is not correct

    [iOS] Location permission status is not correct

    ๐Ÿ› Bug Report

    I request Permission.locationWhenInUse.request() and I choose "Allow Once", the status of locationWhenInUse is granted and the status of locationAlways is permanentlyDenied, and I go to setting page, the location setting status is Ask next time.

    Expected behavior

    the status of locationWhenInUse and locationAlways are granted

    Reproduction steps

    • I request location permission with Permission.locationWhenInUse.request()
    • I go to the screen that has requested location permission
    • The native prompt appears and I choose "Allow Once"
    • The status of locationWhenInUse is granted, status of locationAlways is permanentlyDenied and location permission status in setting page is "ASK NEXT TIME"

    Configuration

    Flutter 2.2.3 iOS 14.5

    Version: 8.1.6

    Platform:

    • [x] :iphone: iOS
    • [ ] :robot: Android
    opened by phuongpham-agilityio 0
  • [iOS 14.5] Location requests don't work

    [iOS 14.5] Location requests don't work

    ๐Ÿ› Bug Report

    I can't seem to make location requests work on iOS, either once, in use or always. The rationale dialog never shows so I can allow or deny the permission. I even tried running the example project. It always returns permission permanently denied.

    SImulator or real iPhone6 it doesn't work.

    Expected behavior

    Permission.location.request() should show the rationale dialog.

    Reproduction steps

    Run the example project in the repository and try to access location permission.

    Configuration

    Flutter 2.5.3 iOS 14.5

    Version: 8.3.0

    Platform:

    • [14.5 ] :iphone: iOS
    platform: ios status: needs more info 
    opened by blkfry 1
  • [iOS 11.4, 15.1] locationAlways.request() not returning when

    [iOS 11.4, 15.1] locationAlways.request() not returning when "When in use"(11.4) "Allow only once"(15.1) selected

    ๐Ÿ› Bug Report

    When requesting location permission with the following two lines, the code execution just stops and the request variable is not is never populated, nor is the return statement ever called. For iOS 11.4: This only happens when the user selects "When in use". When selecting "Always allow", this works fine. For iOS 15.1: This only happens when the user selects "Allow only once". When selecting "When in use", this works fine. So it seems that always when the user selects the not-requested option, the method does not finish its execution.

    var request = await Permission.locationAlways.request();
    return Tuple2(request.isGranted, false); 
    

    Expected behaviour

    The call await Permission.locationAlways.request() should always return a value.

    Reproduction steps

    Use the code above to request the always-on permission and select either "When in Use" on iOS 11.4 or "Allow only once" on iOS 15.1 when asked by iOS. Set a breakpoint right after the call.

    Configuration

    Version: 8.2.6 Flutter: 2.5 Platform:

    • [x] :iphone: iOS
    • [ ] :robot: Android
    opened by flodaniel 1
  • Permission Status always granted when user ontap Dont Allow on iOS

    Permission Status always granted when user ontap Dont Allow on iOS

    Hello :D i found a bug on iOS, when user get poup and choose Dont Allow, The permission status always return PermissionStatus.granted, so user cant load gallery but doesnt show poup anymore. Please help this one thankyou.

    Iphone 11 : iOS 14.7

    platform: ios status: needs more info 
    opened by bwrelawan 1
  • Permission.locationAlways.status gives wrong answer in iOS

    Permission.locationAlways.status gives wrong answer in iOS

    When I first ask permission on iOS for locationWhenInUse and answer with 'Allow While Using App', Permission.locationAlways.status will return granted (even though location access is set to 'While Using the App' and not to 'Always').

    When I manually (in settings) set the permission to 'Never' or 'Ask Next Time' and then back to 'While Using the App', Permission.locationAlways.status will return denied (the correct answer).

    When I first ask permission on iOS for location and answer with 'Allow Once' or 'Don't Allow', Permission.locationAlways.status will return denied (this is correct).

    I use permission_handler: ^8.1.6

    flutter doctor -v
    [โœ“] Flutter (Channel stable, 2.2.1, on macOS 11.6 20G165 darwin-x64, locale en-BE)
        โ€ข Flutter version 2.2.1 at /Users/app/flutter
        โ€ข Framework revision 02c026b03c (5 months ago), 2021-05-27 12:24:44 -0700
        โ€ข Engine revision 0fdb562ac8
        โ€ข Dart version 2.13.1
    
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        โ€ข Android SDK at /Users/merijnmestdagh/Library/Android/sdk
        โ€ข Platform android-30, build-tools 29.0.3
        โ€ข Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        โ€ข Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        โœ— Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    
    [โœ“] Xcode - develop for iOS and macOS
        โ€ข Xcode at /Applications/Xcode.app/Contents/Developer
        โ€ข Xcode 13.0, Build version 13A233
        โ€ข CocoaPods version 1.11.2
    
    [โœ“] Chrome - develop for the web
        โ€ข Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [โœ“] Android Studio (version 4.2)
        โ€ข 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.8+10-b944.6916264)
    
    [โœ“] Connected device (2 available)
        โ€ข Merijnโ€™s iPhone (mobile) โ€ข 00008020-0009601E1199002E โ€ข ios            โ€ข iOS 14.8
        โ€ข Chrome (web)             โ€ข chrome                    โ€ข web-javascript โ€ข Google Chrome 95.0.4638.69
    
    opened by sc00n 5
  • [Android] permission request may return wrong result

    [Android] permission request may return wrong result

    ๐Ÿ› Bug Report

    Permission request may got wrong result on Android platform.

    Let's say two permissions declared in AndroidManifest.xml of a flutter app:

        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
    

    Both of them are Permission.phone on permission_handler dart side.

    On devices running Android 11 and after (Samsung Galaxy Note 20 on my hand)๏ผŒgrant READ_PHONE_STATE but deny READ_PHONE_NUMBERS to the app, then when you request Permission.phone permission on app dart side by [Permission.phone].request(), you got the result {Permission.phone: PermissionStatus.granted} which is incorrect or inaccurate.

    Expected behavior

    Give caller precise status of every manifest permissions, or give denied status if any of them are denied.

    Reproduction steps

    as described above

    Configuration

    Version: 8.2.5

    Platform:

    • [ ] :iphone: iOS not test
    • [x] :robot: Android
    opened by Perfetto2020 1
  • No permission READ_PHONE_STATE about Android

    No permission READ_PHONE_STATE about Android

    ๐Ÿš€ Feature add READ_PHONE_STATE for Android

    Platforms affected (mark all that apply)

    • [ ] :robot: Android
    opened by wenchang1989 3
  • Gets Permission Granted Status for Limited Permission.

    Gets Permission Granted Status for Limited Permission.

    ๐Ÿ› Bug Report

    The Permission.location.status method is returning PermissionStatus.denied if the location service is limited (precise location disabled) in iPhone (>14). (Note: I experience the same for photo access also)

    Expected behaviour

    Expects the plugin to return PermissionStatus.limited while the user has not enabled the precise location in iPhone

    Reproduction steps

    1. Make a fresh install of the app.
    2. Call Permission.location.status which will bring up the iOS permission dialog.
    3. Disable the precise location on the top left corner.
    4. Select on Allow while using the app.
    5. Now the plugin will return permission granted instead of limited state.

    Version: 8.2.2

    Platform:

    • [x] :iphone: iOS 14 +
    • [ ] :robot: Android
    opened by rashidkhaleefa 2
  • Document how to integrate in iOS add-to-app scenario using Frameworks

    Document how to integrate in iOS add-to-app scenario using Frameworks

    ๐Ÿ— Enhancement Proposal

    Better document how to edit the Podfile with an add-to-app using Frameworks Embedding (Option B of integration)

    Pitch

    Our team chose to build our Flutter Module separately from the main project to speed up build times by using cached Frameworks.

    When integrating permission_handler, we wrongly added GCC_PREPROCESSOR_DEFINITIONS flags to the root project instead of in the module package.

    This wasn't picked up by the permission handler build, so we had to move it to the Flutter Module Podfile, which shouldn't even be originaly committed

    The way we documented it was like this:

    Our internal documentation

    For the Flutter module to check for permissions, it uses the permission_handler plugin. As the plugin can handle all types of permissions, Apple may detect as if the app depends on all types of weird permissions (location, wifi, etc).

    To fix this, you need to add the following to the Podfile of the Flutter Module:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        # Other Flutter commands such as flutter_additional_ios_build_settings(target)
    
        if target.name == 'permission_handler'
          target.build_configurations.each do |config|
            # Preprocessor definitions can be found in: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
              '$(inherited)',
    
              ## dart: PermissionGroup.camera
              'PERMISSION_CAMERA=1'
            ]
          end
        end
      end
    end
    

    โ—๏ธ you should add this to the Podfile which builds the Flutter plugins. If you embed Flutter directly on the root project, add it there.

    If it is done separately (by building and embedding Frameworks manually), add it to the Podfile of the Flutter module. This is usually not committed to the repository, but must be included for the module to work properly.

    Platforms affected (mark all that apply)

    • [x] :iphone: iOS
    • [ ] :robot: Android
    platform: ios type: documentation type: enhancement 
    opened by danilofuchs 1
  • App Tracking Transparency prompt not showing on iOS 15

    App Tracking Transparency prompt not showing on iOS 15

    ๐Ÿ› Bug Report

    I noticed the ATT prompt is not showing up on iOS 15. Not on the iOS Simulator and also not on my physical iPhone. See: https://www.reddit.com/r/iOSProgramming/comments/pt41jz/att_prompt_not_showing_on_ios_15/

    Version: 8.1.6

    Platform:

    • [x] :iphone: iOS 15
    platform: ios 
    opened by thegrxp 5
Owner
Baseflow
We provide software, skills and knowledge and with this we want to make a contribution to the world. We love to make innovation happen.
Baseflow
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

Flutter AppAvailability Plugin A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed a

Lorenzo Pichilli 80 Nov 2, 2021
Flutter Downloader - A plugin for creating and managing download tasks. Supports iOS and Android. Maintainer: @hnvn

Flutter Downloader A plugin for creating and managing download tasks. Supports iOS and Android. This plugin is based on WorkManager in Android and NSU

Flutter Community 651 Nov 17, 2021
File picker plugin for Flutter, compatible with both iOS & Android and desktop (go-flutter).

File Picker A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support. Currently s

Miguel Ruivo 706 Nov 27, 2021
Flutter geolocation plugin for Android and iOS.

geolocation Flutter geolocation plugin for Android API 16+ and iOS 9+. Features: Manual and automatic location permission management Current one-shot

Loup 213 Nov 18, 2021
A Flutter plugin for displaying local notifications on Android, iOS and macOS

Flutter Local Notifications plugin This repository consists hosts the following packages flutter_local_notifications: code for the cross-platform faci

Michael Bui 1.7k Nov 23, 2021
Android and iOS Geolocation plugin for Flutter

Flutter Geolocator Plugin A Flutter geolocation plugin which provides easy access to platform specific location services (FusedLocationProviderClient

Baseflow 893 Nov 22, 2021
Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices

ar_flutter_plugin Flutter Plugin for AR (Augmented Reality) - Supports ARKit for iOS and ARCore for Android devices. Many thanks to Oleksandr Leuschen

Lars Carius 80 Nov 24, 2021
Telegram stickers importing Flutter plugin for iOS and Android

TelegramStickersImport โ€” Telegram stickers importing Flutter plugin for iOS and Android TelegramStickersImport helps your users import third-party pro

Iurii Dorofeev 15 Nov 14, 2021
Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android.

flutter_udid Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android. Getting Started import 'package:flutter_udid/flutter_udid.

Leon Kukuk 164 Nov 28, 2021
Support to update the app badge on the launcher (both for Android and iOS)

Flutter App Badger plugin This plugin for Flutter adds the ability to change the badge of the app in the launcher. It supports iOS and some Android de

Edouard Marquez 232 Nov 12, 2021
Flutter library for iOS Widgets Extensions. Integrate a Widget into your App ๐Ÿ๐Ÿ“ฑ

flutter_widgetkit Flutter Library for the iOS ?? WidgetKit framework and Widget Communication Table of Contents ?? Introduction ??โ€?? Installation ??โ€

Fasky 161 Nov 28, 2021
A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.

Flutter InAppWebView Plugin A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser windo

Lorenzo Pichilli 1.7k Nov 29, 2021
A lightweight Flutter plugin for making payments and printing on MyPos

my_poster ?? my_poster is in beta - please provide feedback (and/or contribute) if you find issues ??๏ธ A lightweight Flutter plugin for making payment

Antonio Mentone 3 May 30, 2021
Plugin to access VPN service for Flutter | Flutter ็š„ VPN ๆ’ไปถ

Flutter VPN plugin This plugin help developers to access VPN service in their flutter app. ๆœฌๆ’ไปถๅธฎๅŠฉๅผ€ๅ‘่€…ๅœจ่‡ชๅทฑ็š„ๅบ”็”จๅ†…่ฐƒ็”จ VPN ๆœๅŠกใ€‚ The Android part was implemented

Xdea 204 Nov 19, 2021
Community WebView Plugin - Allows Flutter to communicate with a native WebView.

NOTICE We are working closely with the Flutter Team to integrate all the Community Plugin features in the Official WebView Plugin. We will try our bes

Flutter Community 1.4k Dec 1, 2021
A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting location on Android and iOS. It also provides callbacks when location is changed. Gett

Guillaume Bernos 832 Nov 28, 2021
This is the new version of my Task app "Tasko" which was done in Java. She is now in Flutter for the HotReload and the native Cross-Platform.

tasko_rem The Tasko App is now compatible on iOS, Android and others distribution, because it's made with Flutter โœจ You can now add task, check them o

Scythe 13 Aug 17, 2021
A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc.

dio_http A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout

null 48 Nov 24, 2021
A simple, cross-platform password manager created with Flutter.

PassMan PassMan Logo ยฉ 2021 by Yash Ahir is licensed under CC BY-NC 4.0 A simple, cross-platform password manager created with Flutter. How to run thi

Yash Ahir 17 Oct 25, 2021
A comprehensive guide on learning how to code cross platform mobile applications with the Flutter framework, from the ground up.

โœณ๏ธ The Ultimate Guide to App Development with Flutter โœณ๏ธ A complete and comprehensive guide to learning Flutter with explanations, screenshots, tips,

Anthony 121 Nov 26, 2021
Private, cross-platform package tracking app

LibreTrack Private, cross-platform package tracking app. Track postal items directly on your device using accounts of postal services. The app respect

Yaroslav Pronin 43 Nov 28, 2021
Cross-platform Twitch Chat application with 3rd-party addon support!

Chatsen Chatsen is a cross-platform application that allows you to chat on Twitch with support for 3rd-party services such as 7TV, BTTV and FFZ. It al

Chatsen 82 Dec 1, 2021
A cross platform GUI, soon to be the official GUI.

CCExtractor Flutter GUI The new cross platform interface is all you need, as it includes all the options. After installing GUI you will have a shortcu

CCExtractor Development 13 Sep 29, 2021
Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Ravi Kovind 7 Sep 29, 2021
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

Flutter AppAvailability Plugin A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed a

Lorenzo Pichilli 80 Nov 2, 2021
Converts SVG icons to OTF font and generates Flutter-compatible class. Provides an API and a CLI tool.

Fontify The Fontify package provides an easy way to convert SVG icons to OpenType font and generate Flutter-compatible class that contains identifiers

Igor Kharakhordin 75 Oct 20, 2021
Flutter Advanced: Background Fetch | Run code in the background Android & iOS | Run code in the background Android & iOS

flutterbackground A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you starte

Pawan Kumar 37 Aug 11, 2021
Track your habits day by day and check your result like the GitHub's contributions board

Habits Diary Track your habits day by day and see your result like the GitHub's contributions board Download Support If you want to support this proje

Pigna 25 Nov 19, 2021