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

Overview

Flutter permission_handler plugin

The Flutter permission_handler plugin is build following the federated plugin architecture. A detailed explanation of the federated plugin concept can be found in the Flutter documentation. This means the permission_handler plugin is separated into the following packages:

  1. permission_handler: the app facing package. This is the package users depend on to use the plugin in their project. For details on how to use the permission_handler plugin you can refer to its README.md file. At this moment the Android and iOS platform implementations are also part of this package. Additional platform support will be added in their own individual "platform package(s)".
  2. permission_handler_platform_interface: this packages declares the interface which all platform packages must implement to support the app-facing package. Instructions on how to implement a platform packages can be found int the README.md of the permission_handler_platform_interface package.
Comments
  • 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
  • PlayStore detects `REQUEST_INSTALL_PACKAGES` even when app never uses it

    PlayStore detects `REQUEST_INSTALL_PACKAGES` even when app never uses it

    Hi, we recently got an inbox from Play Store stating that our app contains REQUEST_INSTALL_PACKAGES permission and that we have to declare this on Play Store. However, the problem is we never use it, no calls made to Permission.requestInstallPackages across our codebase.

    The question is, how do I remove unused permission requests from our app? If currently not possible, is there any suggestion?

    image

    platform: android 
    opened by iandis 59
  • 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
  • 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 30
  • 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
  • FileSystemException: Cannot open file....(OS Error: Permission denied, errno = 13)

    FileSystemException: Cannot open file....(OS Error: Permission denied, errno = 13)

    I cannot select image from gallery. This is my logcat FileSystemException: Cannot open file, path = '/storage/emulated/0/DCIM/s9camera/Pic_2020_06_04_19_36_15.jpg' (OS Error: Permission denied, errno = 13). I'm using permission_handler package for handle permission. Storage and Access Media Location permission has already granted by user but the issue is generated every time when pick image or video from external storage. Inside manifest file we have added android:requestLegacyExternalStorage="true" Suddenly i get issue on the production app , please support us

    opened by prasantco 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{who=@android: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 28
  • [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 26
  • 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
  • Always says

    Always says "No permissions found in manifest"

    💬 Questions and Help

    Hello,

    I copied and paste the example: https://github.com/BaseflowIT/flutter-permission-handler/tree/develop/example both main.dart and the permissions inside AndroidManifest.xml.

    The message is always the same:

    Launching lib/main.dart on SM G935F in debug mode...
    Initializing gradle...
    Resolving dependencies...
    Running Gradle task 'assembleDebug'...
    Built build/app/outputs/apk/debug/app-debug.apk.
    Installing build/app/outputs/apk/app.apk...
    Syncing files to device SM G935F...
    D/libGLESv2( 2235): STS_GLApi : DTS, ODTC are not allowed for Package : com.example.flutter_app
    D/permissions_handler( 2235): No permissions found in manifest for: $permission
    I/chatty  ( 2235): uid=10519(u0_a519) com.example.flutter_app identical 5 lines
    D/permissions_handler( 2235): No permissions found in manifest for: $permission
    D/permissions_handler( 2235): No permissions found in manifest for: $permission
    I/chatty  ( 2235): uid=10519(u0_a519) com.example.flutter_app identical 3 lines
    D/permissions_handler( 2235): No permissions found in manifest for: $permission
    D/ViewRootImpl@6bcba18[MainActivity]( 2235): ViewPostIme pointer 0
    D/ViewRootImpl@6bcba18[MainActivity]( 2235): ViewPostIme pointer 1
    D/permissions_handler( 2235): No permissions found in manifest for: $permission
    I/flutter ( 2235): decodePermissionRequestResult called with: value:[{0: 4}]
    I/flutter ( 2235): {PermissionGroup.calendar: PermissionStatus.unknown}
    I/flutter ( 2235): PermissionStatus.unknown
    

    No matter what I do. Even tried more simple code, like just asking for one permission clicking a button.

    I do have all the permissions on manifest.

    Any clues?

    opened by vendramini 23
  • 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
  • Storage permission dined in Android

    Storage permission dined in Android

    My app have a problem with STORAGE permission in Android version: 13, it returns false always and don't show allow permission popup when I use the following line: await Permission.storage.request().isGranted

    permission_handler: ^10.2.0 Flutter version: 3.3.10

    My permissions in AndroidManifest.xml are here:

        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
        <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
        <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
        <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove" />
       
        <queries>
            <intent>
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme="https" />
            </intent>
            <intent>
                <action android:name="android.intent.action.DIAL" />
                <data android:scheme="tel" />
            </intent>
            <intent>
                <action android:name="android.intent.action.SEND" />
                <data android:mimeType="*/*" />
            </intent>
        </queries>
    
    opened by blue492 1
  • Crash: Permission Denial: ... requires null, or grantUriPermission()

    Crash: Permission Denial: ... requires null, or grantUriPermission()

    🐛 Bug Report

    Firebase Crashlytics reports the following crash:

    Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
           at android.os.AsyncTask$4.done(AsyncTask.java:399)
           at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
           at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
           at java.util.concurrent.FutureTask.run(FutureTask.java:271)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
           at java.lang.Thread.run(Thread.java:919)
    
    Caused by java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=3296, uid=10475 requires null, or grantUriPermission()
           at android.os.Parcel.createException(Parcel.java:2074)
           at android.os.Parcel.readException(Parcel.java:2042)
           at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)
           at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
           at android.content.ContentProviderProxy.query(ContentProviderProxy.java:423)
           at android.content.ContentResolver.query(ContentResolver.java:946)
           at android.content.ContentResolver.query(ContentResolver.java:881)
           at android.content.ContentResolver.query(ContentResolver.java:837)
           at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.getCursor(ContactsServicePlugin.java:521)
           at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.access$500(ContactsServicePlugin.java:55)
           at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:451)
           at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:427)
           at android.os.AsyncTask$3.call(AsyncTask.java:378)
           at java.util.concurrent.FutureTask.run(FutureTask.java:266)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
           at java.lang.Thread.run(Thread.java:919)
    

    We are getting about 200 crash events monthly on different devices and Android versions (with over 500K monthly users). The crash is related to the denial of permission for the user's contacts. Generally, when such an exception is thrown, it tells you what permission is missing, such as requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS. But in our case, it says that requires null, or grantUriPermission().

    Our application only reads the user's contacts, so we have <uses-permission android:name="android.permission.READ_CONTACTS" /> in the AndroidManifest.

    We tried to reproduce the issue, but couldn't.

    Configuration

    [√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale ru-RU)
        • Flutter version 3.0.5 at C:\tools\flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision f1875d570e (6 months ago), 2022-07-13 11:24:16 -0700
        • Engine revision e85ea0e79c
        • Dart version 2.17.6
        • DevTools version 2.12.2
    
    [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at C:\Users\k_tashbaev\AppData\Local\Android\sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
        • All Android licenses accepted.
    
    [√] Chrome - develop for the web
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [X] Visual Studio - develop for Windows
        X Visual Studio not installed; this is necessary for Windows development.
          Download at https://visualstudio.microsoft.com/downloads/.
          Please install the "Desktop development with C++" workload, including all of its default components
    
    [√] Android Studio (version 2021.3)
        • Android Studio at C:\Program Files\Android\Android Studio
        • 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.73.1)
        • VS Code at C:\Users\k_tashbaev\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension can be installed from:
    [√] Connected device (3 available)
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.1889]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 108.0.5359.125
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 92.0.902.67
    
    [√] HTTP Host Availability
        • All required HTTP hosts are available
    

    Version: 10.2.0

    Platform:

    • [ ] :iphone: iOS
    • [x] :robot: Android
    opened by tkas9mbek 1
  • Location Permission Not Appearing for Aplications with Permission Handler Plugin on iOS 16.1

    Location Permission Not Appearing for Aplications with Permission Handler Plugin on iOS 16.1

    I am experiencing an issue with the Permission Handler plugin in Flutter on iOS devices running version 16.1.

    When a Flutter app that uses the Permission Handler plugin with the location permission is installed with the iOS "Location services" setting turned off, the location permission option does not appear in the app's configuration when the "Location services" setting is later turned on. As a result, users are unable to grant the location permission to the app, and the permission request is always denied.

    I have already confirmed that I have correctly configured the location permission in my Flutter app according to the instructions in the Permission Handler plugin documentation, and I have checked for any known issues or workarounds related to the plugin on its GitHub page. However, the issue persists.

    Could you please provide some guidance on how to resolve this issue? Any help would be greatly appreciated.

    Thank you!

    Platform:

    • [X] :iphone: iOS
    • [ ] :robot: Android
    opened by yamauchieduardo 0
  • How i can show the pop up for using ble device on android i already have the manifest needed also

    How i can show the pop up for using ble device on android i already have the manifest needed also

    as my manifest

    <uses-permission android:name="android.permission.BLUETOOTH" />
      <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
      <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
      <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
      <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
      <uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
      <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
    

    then i tried to request for bluetooth await Permission.bluetooth.request()

    just nothing happens only showing is the location and others

    am using physical device android 10

    opened by Erchil66 0
  • Caused by java.lang.NullPointerException Attempt to invoke interface method 'void com.baseflow.permissionhandler.n$b.a(java.util.Map)' on a null object reference

    Caused by java.lang.NullPointerException Attempt to invoke interface method 'void com.baseflow.permissionhandler.n$b.a(java.util.Map)' on a null object reference

    🐛 Bug Report

    Crashlytics - Stack trace

    Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=210, result=-1, data=Intent { (has extras) }} to activity {com.xxx/com.xxx.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.baseflow.permissionhandler.n$b.a(java.util.Map)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:5567) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5606) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2374) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:233) at android.os.Looper.loop(Looper.java:344) at android.app.ActivityThread.main(ActivityThread.java:8248) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)

    Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void com.baseflow.permissionhandler.n$b.a(java.util.Map)' on a null object reference at com.baseflow.permissionhandler.PermissionManager.onActivityResult(PermissionManager.java:100) at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:840) at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:441) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:772) at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:685) at android.app.Activity.dispatchActivityResult(Activity.java:8472) at android.app.ActivityThread.deliverResults(ActivityThread.java:5560) at android.app.ActivityThread.handleSendResult(ActivityThread.java:5606) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2374) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:233) at android.os.Looper.loop(Looper.java:344) at android.app.ActivityThread.main(ActivityThread.java:8248) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)

    Expected behavior

    Reproduction steps

    Configuration

    Version: 1.x permission_handler: 9.0.2

    Platform:

    • [ ] :iphone: iOS
    • [ x ] :robot: Android
    opened by Super-Bin 0
  • Fix App Tracking Transparency request may fail to show.

    Fix App Tracking Transparency request may fail to show.

    :sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

    Fix App Tracking Transparency authorization prompt may fail to show in iOS, due to iOS not showing the prompt unless the app is in an Active state. This often happens when multiple permissions are requested and App Tracking Transparency come after any other authorization prompts.

    :arrow_heading_down: What is the current behavior?

    When multiple permissions are requested at once (at client level), and App Tracking Transparency is in the middle of those permissions, the authorization prompt for App Tracking Transparency does not show and the plugin simply return "Denied" as permission authorization state.

    :new: What is the new behavior (if this is a feature change)?

    When multiple permissions are requested at once, App Tracking Transparency authorization request will first wait until the app is active again. This would normally happen after the last permission authorization request is dismissed. If the app is already in active state, App Tracking Transparency authorization will be asked immediately.

    :boom: Does this PR introduce a breaking change?

    No.

    :bug: Recommendations for testing

    Use this code on client, and run it on iOS devices.

    Permission.notification.request();
    Permission.appTrackingTransparency.request();
    

    :memo: Links to relevant issues/docs

    • https://github.com/Baseflow/flutter-permission-handler/issues/676
    • https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/3547037-requesttrackingauthorizationwith?language=objc

    :thinking: Checklist before submitting

    • [x] I made sure all projects build.
    • [x] I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
    • [x] I updated CHANGELOG.md to add a description of the change.
    • [x] I followed the style guide lines (code style guide).
    • [x] I updated the relevant documentation.
    • [x] I rebased onto current master.
    opened by luiges90 0
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
This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.

Flutter Permission Plugins Deprecation Notice This repository has been replaced by the Flutter permission_handler plugin and will not longer be mainta

Baseflow 51 Dec 13, 2021
A sample app of using the image_picker + path_provider and permission_handler package to request permission and store photos on mobile

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

iang12 4 Apr 19, 2022
MedRec: Using Blockchain for Medical Data Access and Permission Management

MedRec Medical records need innovation. Patients leave data scattered across various jurisdictions as life events take them away from one provider’s d

Abhishek Kumar 4 Sep 14, 2022
Api Call Check flutter - A new Flutter project that demonstrates api calling and displays them in a scrollable list

api_fetch A new Flutter project that demonstrates api calling and displays them

Babish Shrestha 0 Jan 2, 2022
A package help you to make api call and handle error faster, also you can check for internet before call api.

http_solver ##not for production use, only for learning purpose. A package help you to make api call and handle error faster, also you can check for i

Abdelrahman Saed 1 Jun 18, 2020
A cross-platform WebView for Android, iOS and Web.

A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready. Getting started Gallery Basic usage Featu

Mahad Asghar 4 Dec 14, 2022
Aditya 93 Dec 25, 2022
Youtube API in Dart app. Used for downloading media and search request.

Youtube API Youtube API made by using Dart and Flutter in a cross-platform app. Used for downloading media and search request. For an idea of how the

Avian Silviu-Gabriel 0 Nov 4, 2021
Hava Durumu Uygulaması - Temel Api Request

Hava Ne Durumda Bu uygulama temelde apilerle nasıl çalışılır, apiden veri nasıl GET edilir gibi işlemleri anlamak için yapılmıştır. Uygulama Fotoğrafl

Mehmet Ege Aydın 4 Jun 14, 2022
Morphing Coffee 0 Jan 27, 2022
Flutter-for-Wordpress-App - Cross platform wordpress news app built with Flutter and WP REST API

Flutter for Wordpress A flutter app for a wordpress websites with clean and elegant design. This app is available in free and pro version. You can cho

Madhav Poudel 243 Dec 23, 2022
A Flutter plugin to request the device unlock screen.

device_unlock A Flutter plugin to request the device unlock screen on Android and iOS. How does it work The following attempts and fallbacks are made:

Cíngulo 19 Sep 7, 2022
ESP-Touch Dart API for Flutter. Platform-specific implementation for Android (Java) and iOS (Objective-C).

esptouch_flutter Flutter plugin for ESP-Touch to configure network for ESP-8266 and ESP-32 devices. Runs on iOS and Android. esptouch_flutter is Flutt

SMAHO Engineering OSS 86 Dec 10, 2022
This project is Riot game information check service using Riot api.

riot_api_project this project is Riot game information check service using Riot api. Getting Started This project is a starting point for a Flutter ap

null 1 Dec 12, 2021
A Flutter plugin that provides assets abstraction management APIs without UI integration, you can get assets (image/video/audio) on Android, iOS and macOS.

photo_manager Photo/Assets management APIs for Flutter without UI integration, you can get assets (image/video/audio) from Android, iOS and macOS. 提供相

FlutterCandies 526 Jan 4, 2023
Cross-platform flutter plugin for reading and writing NFC tags. Not maintained anymore - not looking for new maintainer, fork instead.

nfc_in_flutter NFC in Flutter is a plugin for reading and writing NFC tags in Flutter. It works on both Android and iOS with a simple stream interface

Andi Semler 113 Sep 28, 2022
Simple and hackable request for dart

Simple and hackable request for dart

Thiago da Silva Teixeira 2 Sep 22, 2022
Http request inspector for Flutter application

Alice Alice is an HTTP Inspector tool for Flutter which helps debugging http requests. It catches and stores http requests and responses, which can be

Hau Tran 8 Dec 14, 2022
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 46 Dec 19, 2021