Git Product home page Git Product logo

flutter-permission-plugins's People

Contributors

filipproch avatar j3g avatar japborst avatar josh-burton avatar leonardosilva-asaas avatar lootwig avatar martijn00 avatar mvanbeusekom avatar stijnwoerkom avatar vincekruger avatar wwwdata avatar yunyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter-permission-plugins's Issues

[location_permissions] Supporting the v2 plugin embedding API

πŸš€ Feature Requests

Flutter v1.12.13 stable has been published since 2019/12/11, now we are using new Android plugin APIs.
According to https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration, we can use plugins easier in our flutter apps, e.g. we don't need to register plugins any more, they will be attached to engine automatically.
location_permissions plugin is now using old APIs, and the is not compatible with new plugin framework.

Contextualize the feature

When the app is using v2 plugin embedding APIs, location_permissions plugin is not working, because the framework register the plugins using old APIs without Activity context.
I can resolve the problem by calling FeatureLocationPlugin.registerWith in FlutterActivity.configureFlutterEngine, but I think it will be better if the new APIs is being used.

Describe the feature

https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration

Platforms affected (mark all that apply)

  • [Γ—] πŸ“± iOS
  • [√] πŸ€– Android

Issue with the checkPermissionStatus on Android when the user selects "Allow only while using the app"

Hi!

I updated to the latest version(3.0.0+1), and I have an issue with the checkPermissionStatus on Android when the user selects "Allow only while using the app".
Basically, when the prompt appears in Android:

  • If the user click in "Allow all the time", checkPermissionStatus return "granted" (which is fine)
  • If the user clicks in "Deny", checkPermissionStatus return "denied", (also fine)
  • If the user clicks in "Allow only while using the app", checkPermissionStatus return "denied" (here is the problem). But requestPermissions return "granted".

On IOS all good.

Android 11 support problem

πŸš€ Feature Requests

Android 11 update added support for One-time permissions. Now users have ability to accept permission for only one time.
This library needs to add support for this feature because now the library reports false positive in next app usage.

Steps:

  1. Open app
  2. When asked for permission choose "Only this time"
  3. Restart app
  4. Plugin reporting that permission is accepted although it is not

Platforms affected (mark all that apply)

  • πŸ“± iOS
  • [Y] πŸ€– Android

Enums are in the wrong order on the Read Me (on pub.dev).

πŸ› Bug Report

In source code it shows the enum for PermissionStatus as:
enum PermissionStatus {
unknown,
denied,
granted,
restricted,
}
But in the Readme on pub.dev it shows the enum as:
enum PermissionStatus {
denied,
granted,
restricted,
unknown
}

Expected behavior

Reproduction steps

Configuration

Version: 2.0.4+1

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Revoking permissions on Android causes crash

πŸ› Bug Report

Revoking permissions via phone settings, causes the app to crash.

Expected behavior

Revoking permissions handled gracefully.

Reproduction steps

With app open at a map, navigate to settings and revoke permissions for the app.

Version: 2.0.4+1
with google_maps_flutter: ^0.5.24+1

Platform:

  • πŸ“± iOS
  • [ x ] πŸ€– Android

Will these packages eventually replace the permission_handler package?

I remember reading in one of the issues that Baseflow wanted to make every single permission in to their seperate packages like this package. Is this strategy still valid? I see there is not much activity in this repo and just wanted to be sure.

We need this package at least for the locationServicesEnabled Stream which is not found in any other plugin. Thanks for that since it is very useful.

However, we need to use many packages for very similar things. Geolocator, Permission_handler, location_permission and it is hard to manage and read our own code after a while.

So I will be very glad if you could share some of your plans for the future. Thanks

Bonus question: What might be the reason I get PermissionStatus.denied from LocationPermissions().requestPermissions() without iOS showing the location request dialog?

[iOS] Requesting location always permissions does not return status when requesting more than once or selecting while using

πŸ› Bug Report

Upon either selecting while using after first requesting for always permissions or requesting for always permissions more than once, method hangs and does not return permission status.

Expected behavior

Method would return PermissionStatus.denied when user selects while using and return current PermissionStatus in additional calls to request always permissions.

Reproduction steps

  • Request while using permissions
  • Grant while using permissions
  • Request always permissions
  • Select while using in popup

Configuration

Version: 3.0.0+1

Platform:

  • πŸ“± iOS
  • πŸ€– Android

AndroidManifest need ACCESS_FINE_LOCATION permission?

Initially when my app called

LocationPermissions().requestPermissions(
permissionLevel: LocationPermissionLevel.locationWhenInUse);

No dialog would get displayed to allow the user to grant or deny the permission. But after adding

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

to my AndroidManifest.xml file, the dialog would show up. I didn't see that mentioned in the documentation. This was on a device running Android 6.0.1.

CheckPermissionStatus returns denied after granted was returned when requesting permissions

PermissionStatus geolocationPermissionStatus = await _locationPermissions.requestPermissions(permissionLevel: LocationPermissionLevel.locationWhenInUse);

returns PermissionStatus.granted

but after that

final PermissionStatus geolocationPermissionStatus = await _locationPermissions.checkPermissionStatus(level: LocationPermissionLevel.locationWhenInUse);

returns PermissionStatus.denied

On my manifest I have only this

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Originally posted by @DenisBogatirov in #21 (comment)

shouldShowRequestPermissionRationale always returns false

πŸ”™ Regression

shouldShowRequestPermissionRationale() receives a Context, but updates to onMethodCall() guarantees that it is not an Activity, and will always log an error and return false.

Old (and correct) behavior

onMethodCall() saved a final reference to a Context via a deleted method getActiveContext(), which used either mRegistrar.activeContext() or mRegistrar.activity().

That Context was passed to shouldShowRequestPermissionRationale(), which checked if it was instanceof an Activity, which would succeed if mRegistrar.activity() was called in getActiveContext().

Current behavior

onMethodCall() saves a final reference to a Context via mRegistrar.context(). From the documentation, that method returns the Application's Context, which by definition will not be an Activity, thereby guaranteeing the error in shouldShowRequestPermissionRationale() and returning false.

Reproduction steps

Call LocationPermissions().shouldShowRequestPermissionRationale() in Flutter.

Suggested Steps

In onMethodCall(), I suggest replacing
final Context context = mRegistrar.context();
with
final Context context = mRegistrar.activeContext();
The documentation states that it returns the current Activity, or the Application if that's null, which is exactly what the getActiveContext() method was trying to do. As I'm not familiar with the rest of the logic, a cursory review of the other methods that accept a Context from onMethodCall() seem to be unaffected by this change.

Relevant Commit

8bd14831582fda4b74855e9dabc43fe4c5f99307

Version: 2.0.1

Platform:

  • πŸ“± iOS
  • πŸ€– Android

【ServiceStatus】 is conflict in 2.0.4+1

πŸ› Bug Report

The name 'ServiceStatus' is defined in the libraries 'package:location_permissions/src/permission_enums.dart (via package:location_permissions/location_permissions.dart)' and 'package:permission_handler/src/permission_enums.dart'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.dart
image

we should hide one of them to avoid this problem

On iOS 13, location always is incorrectly returned as granted when you only have when in use

πŸ› Bug Report

NOTE: Yes I saw the closed issue where it was stated this was fixed and yes I'm using the hotfix location_permissions: 3.0.0+1

Expected behavior

Upon asking for location permissions and the user taps "when in use", location always is not yet granted.

Reproduction steps

  • Use iOS 13 device
  • Prompt for location permissions and select "when in use"
  • Check if permission level for location always

This returns true:

  static Future<bool> hasLocationAlwaysPermission() async {
    PermissionStatus permission = await LocationPermissions()
        .checkPermissionStatus(level: LocationPermissionLevel.locationAlways);

    return permission == PermissionStatus.granted;
  }

image

Platform:

  • πŸ“± iOS 13 (not 12 and lower, seems to work)
  • πŸ€– Android (all android devices tested work as well)

HandlePermissionsRequest after call activity request permission unexpected behavior on Android Q

πŸ› Bug Report

Description:

  • Call request permission with LocationPermissionLevel.locationAlways -> user presses Deny
  • checkPermissionStatus returns Denied -> call request permission again -> user presses allow why using this app
  • checkPermissionStatus returns Denied -> call request permission again -> user presses Keep and don't ask again
  • checkPermissionStatus again -> return permission is granted --> wrong

Expected behavior

  • The last time when I call checkPermissionStatus again -> return permission is denied

Reproduction steps

Configuration

Version: 1.x

Platform:

  • πŸ“± iOS
  • πŸ€– Android

I debuged and detect that code block below is wrong

private void handlePermissionsRequest(String[] permissions, int[] grantResults) {
    if (mResult == null) {
      Log.e(LOG_TAG, "Flutter result object is null.");
      return;
    }

    for (int i = 0; i < permissions.length; i++) {
      if (LocationPermissionsPlugin.isLocationPermission(permissions[i])) {
        @PermissionStatus int permissionStatus = toPermissionStatus(grantResults[i]);

        processResult(permissionStatus);
        return;
      }
    }

    processResult(PERMISSION_STATUS_UNKNOWN);
  }

because on Android Q, we have 3 different types of permission, and location permission is only granted if we granted all of those.
I think the code block below is true

private void handlePermissionsRequest(String[] permissions, int[] grantResults) {
    if (mResult == null) {
      Log.e(LOG_TAG, "Flutter result object is null.");
      return;
    }

    for (int i = 0; i < permissions.length; i++) {
      if (LocationPermissionsPlugin.isLocationPermission(permissions[i])) {
        @PermissionStatus int permissionStatus = toPermissionStatus(grantResults[i]);
        if (permissionStatus == PERMISSION_STATUS_DENIED) {
          processResult(permissionStatus);
          return;
        }
      }
    }

    processResult(PERMISSION_STATUS_GRANTED);
  }

iOS permission key search is incomplete

πŸ› Bug Report

Using XCode 12.1 & iOS 14.1, there is an additional location permission key which is ignored by this plugin. The key in question is 'NSLocationAlwaysAndWhenInUseUsageDescription' which is an amalgamation of the handled keys 'NSLocationWhenInUseUsageDescription' and 'NSLocationAlwaysUsageDescription'. The current code does not have a check for this "new" key. Although I am a novice wrt to Flutter plugins, I will try to create a pull request.

Expected behavior

To not throw an exception when the key 'NSLocationAlwaysAndWhenInUseUsageDescription' is used in the Info.plist.

Reproduction steps

Define 'NSLocationAlwaysAndWhenInUseUsageDescription' in Info.plist. Debugging the app demonstrates that an exception is thrown -

Exception has occurred.
PlatformException (PlatformException(ERROR_MISSING_PROPERTYKEY, To use location in iOS8 you need to define either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in the app bundle's Info.plist file, null, null))

Configuration

Version: 1.x

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Separate plugins for Location, Camera, Storage, etc

πŸ— Enhancement Proposal

  1. Extract/abstract out common pieces to flutter-permission-plugins/packages/permission_handler
  2. location_permissions will then depend on permission_handler and inject/override location specific strings / methods
  3. camera_permissions will depend on permission_handler and inject/override camera+mic specific strings / methods
  4. same for Storage and others

Pitch

I can submit initial PRs later today / tomorrow. Might need little help with iOS side

Platforms affected (mark all that apply)

  • πŸ“± iOS
  • πŸ€– Android

Unable to compile in my app

πŸ› Bug Report

Can't add this to my app. I am using the latest build. When I download the source and build that separately everything works fine and compiles and runs but not in my android app.

                                                                                                   ^

symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
F:\flutter.pub-cache\hosted\pub.dartlang.org\location_permissions-2.0.5\android\src\main\java\com\baseflow\location_permissions\LocationPermissionsPlugin.java:310: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && hasPermissionInManifest(Manifest.permission.ACCESS_BACKGROUND_LOCATION, context)) {
^
symbol: variable Q
location: class VERSION_CODES
F:\flutter.pub-cache\hosted\pub.dartlang.org\location_permissions-2.0.5\android\src\main\java\com\baseflow\location_permissions\LocationPermissionsPlugin.java:310: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && hasPermissionInManifest(Manifest.permission.ACCESS_BACKGROUND_LOCATION, context)) {
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
F:\flutter.pub-cache\hosted\pub.dartlang.org\location_permissions-2.0.5\android\src\main\java\com\baseflow\location_permissions\LocationPermissionsPlugin.java:311: error: cannot find symbol
permissionNames.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
^
symbol: variable ACCESS_BACKGROUND_LOCATION
location: class permission
5 errors

FAILURE: Build failed with an exception.

Expected behavior

Reproduction steps

Configuration

Version: 2.0.5

build.gradle is set to compileSdkVersion 29 and I'm using AndroidX so should not be a problem.

Platform:
Android

iOS Permission Best Practices

πŸ— Enhancement Proposal

I have been evaluating the popular location permission libraries with flutter to see how it matches with the best practices. Below is what I found with your library. Let me know if there are ways to get this to work that I missed.

Pitch

So below is my understanding of the best practices. You can see Google Maps and other apps doing the below

If (Location Services Disabled)
    A) Show Location Services Dialog
        Redirect to Location Services Settings
else if(Location permission denied)
    B) Show Dialog saying to enable permission
        Redirect to App Settings
else
    C) Show Permission dialog

So the library does not support
A. The library does not show the dialog that gives the user the option to enable location services.

B. The library ignores the permission request. It would be good if you had an option to show a dialog and redirect to the app settings.

Summary
I think these are the changes required for users of the library to implement permissions.

  1. Show dialog to enable location services when location services are disabled.
  2. Automatically show a dialog that we can pass the title and message when requesting location when permission denied. Have an option to not do that automatically.
    Let me know if you need any clarification.

Platforms affected (mark all that apply)

  • [X ] πŸ“± iOS
  • πŸ€– Android

Multiple bugs when we deny location permission and then ask for it again

πŸ› Bug Report

These are minor bugs but I wanted to report them anyway. There are actually 3 different bugs but I believe they are related so I'm reporting them as one.

Expected behavior

Bug A

there shouldn't be ERROR_ALREADY_REQUESTING_PERMISSION

Bug B

Request permission pop up shouldn't get stuck and should pop up right away.

Bug C

There should NOT be this error:
IMG_13BCC33E7FB4-1

Reproduction steps

For reproduction, please see this repo: https://github.com/tomasbaran/location_permissions

Bug A

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Go back to the app
  5. Tap Don't Allow
  6. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  7. Now it throws an error which I don't believe makes sense since there was no requested permission running: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSION, A request for permissions is already running, please wait for it to finish before doing another request., null)

Bug B

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Ask Next Time (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Wait 10 seconds (if you don't wait for 10 seconds and you do it right away, everything works as it should)
  5. Go back to the app
  6. The Requested Permission Pop up got stuck: doesn't throw any error but doesn't pop up the Permission request.

This issue always happens on Simulator and sometimes happens on real iPhone sometimes not

Bug C

  1. Tap Don't Allow
  2. Tap Enable Location
  3. Set Allow Always (but iOS doesn't refresh the status, so please go back one step and then do it)
  4. Go back to the app
  5. Throws a '!debugLocked is not true' error

Configuration

Version: 2.0.5

Platform:

  • πŸ“± iOS
  • πŸ€– Android

requestPermissions fails after checkPermissionStatus is called on iOS

πŸ› Bug Report

If requestPermissions is called, this exception is thrown:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSION, A request for permissions is already running, please wait for it to finish before doing another request., null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564)
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302)
<asynchronous suspension>
#2      LocationPermissions.requestPermissions (package:location_permissions/src/location_permissions.dart:70)
<asynchronous suspension>
#3      LocationRequest._requestPerms (package:social_dating/location_request.dart:15)
<asynchronous suspension>
#4      LocationRequest.build.<anonymous closure> (package:social_dating/location_request.dart:51)
#5      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511)
#6      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566)
#7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166)
#8      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240)
#9      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177)
#10     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436)
#11     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73)
#12     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101)
#13     _RenderingFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:221)
#14     _RenderingFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199)
#15     _RenderingFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156)
#16     _RenderingFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102)
#17     _RenderingFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86)
#18     _rootRunUnary (dart:async/zone.dart:1136)
#19     _CustomZone.runUnary (dart:async/zone.dart:1029)
#20     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931)
#21     _invoke1 (dart:ui/hooks.dart:233)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:154)

Expected behavior

This should work with no exception.

Reproduction steps

  • First call await checkPermissionStatus
  • Then call await requestPermissions

Version: 2.0.0

Platform:

  • πŸ“± iOS
  • πŸ€– Android

[location][ios] whenInUse returns denied

πŸ› Bug Report

When requesting location permission on iOS, the user selects "only when in use." The plugin returns "denied."

Expected behavior

"Granted," or maybe "restricted." (Have I misunderstood the semantics here? If it's a matter of what the default PermissionLevel.location means on Android vs iOS, please document the difference!)

Reproduction steps

From a Flutter iOS app, call requestPermissions(). Choose "When in use" from the prompt. See "denied" logged as the return value.

https://github.com/BaseflowIT/flutter-permission-plugins/blob/develop/packages/location_permissions/ios/Classes/LocationPermissionsPlugin.m#L195

https://github.com/BaseflowIT/flutter-permission-plugins/blob/develop/packages/location_permissions/ios/Classes/LocationPermissionsPlugin.m#L108

Configuration

Version: 2.0.2

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Is there any plans to support Web version?

πŸš€ Feature Requests

That would be great to have the support of the Web version as well.

Contextualize the feature

Web usage of Flutter applications is a killer feature and all the plugins should be supported in Web

Describe the feature

It's possible to ask permissions both in desktop and mobile browsers, so it should be possible to add support of the Web platform to this plugin

Platforms affected (mark all that apply)

  • :web: Web

Null Safety Support

πŸ— Enhancement Proposal

Hello, are there any plans for supporting null safety.

Pitch

As Null Safety is officially out, all packages should migrate to null safety so Apps can too!

Android permission allowWhenAppInUse triggering inactive and resumed appLifeStateEvent

πŸ› Bug Report

My application retrieving user location data every 3 seconds. On Android when i choose permission as allowAlways everything works ok. But if i choose allowWhenAppInUse permission, it asks same requestPermission dialog everytime app fetches location (ie every 3 seconds), and if i further press allowWhenAppInUseAndDoNotAskAgain , then app lifecycle state starts to constantly change from inactive to resumed everytime location is fetched. Inactive state can be reached when app have another activity ontop of it, so i assume that requestPermission dialog is somehow showing and poping quickly every 3 second , and it triggers app lifecycle event to change to inactive then to resume and again same cycle.

Version: 3.0.0 +1

Platform:

  • [+ ] πŸ€– Android

Android Permission Best Practices

πŸ— Enhancement Proposal

I have been evaluating the popular location permission libraries with flutter to see how it matches with the best practices. Below is what I found with your library. Let me know if there are ways to get this to work that I missed.

Pitch

Android Best Practices
https://developer.android.com/distribute/best-practices/develop/runtime-permissions
https://developer.android.com/training/permissions/requesting
So below is my understanding of the best practices.

if (Location Services Disabled)
    A) Show Location Services Dialog 
else if (Location Services Enabled)
    If(Permission Denied Forever)
        B) Show Dialog that says permission denied forever and will show Settings
            C) Redirect to app settings
    else if(Denied Once && Permission Rational provided)
        D) Show Permission Rational
                  Show Permission Dialog
    else
        E) Show Permission Dialog

So the library does not support
A. The library does not automatically show the location services enable dialog. This library does if you need a code reference https://github.com/loup-v/geolocation
B/C. So if permissions are denied forever I would think it would be best to show some sort of dialog before redirecting the user to the settings page. The library does not redirect the user to the settings page or show the dialog before as I think it should. So maybe when requesting permission we can pass this message and you show it in a dialog before going to the settings page. Also might want to expose the neverAskAgain like you have in here
https://github.com/Baseflow/flutter-permission-handler/blob/develop/lib/src/permission_enums.dart
D. It would be great if when requesting permission that the permission rational could be passed in so your library would show the dialog and after they confirm they get taken to the grant page again.

Summary
I think these are the changes required for users of the library to implement permissions.

  1. Show enable location services dialog when its disabled
  2. Return denied forever from the permissions enum. Give developer option to redirect user to app settings if denied forever. Also show a dialog before redirecting to app settings that the developer can send in the text for.
  3. Have permission rational be something we pass in when requesting permissions so the library can handle showing it and showing the grant permission dialog.

Platforms affected (mark all that apply)

  • πŸ“± iOS
  • [X ] πŸ€– Android

cannot find symbol return locationManager.isLocationEnabled()

πŸ› Bug Report

error: cannot find symbol
return locationManager.isLocationEnabled();
^
symbol: method isLocationEnabled()
location: variable locationManager of type LocationManager
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':location_permissions:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 33s
Finished with error: Gradle task assembleDebug failed with exit code 1

Version: 2.0.2

Platform:

  • πŸ€– Android

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'

πŸ› Bug Report

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 10s


The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.


Finished with error: Gradle task assembleDebug failed with exit code 1

Expected behavior

Reproduction steps

after adding location_permissions library I receive an error in the android build process

Configuration

environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

cupertino_icons: ^0.1.2
numberpicker: ^1.0.0
google_maps_flutter: ^0.5.5
location_permissions: ^1.0.2

dev_dependencies:
flutter_test:
sdk: flutter

Version: 1.x

Platform:

  • πŸ“± iOS
  • πŸ€– Android

iOS "Ask Next Time" permission status return "unknown"

I'm wondering how to identify this setting (when the user sets Location to "Ask Next Time"). It comes back as PermissionStatus.unknown - my assumption would have been that it would instead come back as PermissionStatus.restricted maybe?

LocationPermissionsPlugin.java uses or overrides a deprecated API

πŸ› Bug Report

Note: . . .location_permissions-4.0.0/android/src/main/java/com/baseflow/location_permissions/LocationPermissionsPlugin.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.


Thanks for looking into this.

[android] checkPermissionStatus returns PermissionStatus.denied even when not asked for permission

πŸ› Bug Report

The library doesn't provide an unified API across iOS and Android.

On iOS, it returns PermissionStatus.unknown when not asked for permission.

On Android, it returns PermissionStatus.denied, so it is impossible to say whether we asked for permission and the user declined to grant it, or we didn't ask at all.

Configuration

Version: 2.0.4+1

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Add permissions levels on Android

πŸš€ Feature Requests

Add permissions levels support for the Android platform

Contextualize the feature

The LocationPermissions().checkPermissionStatus(level: LocationPermissionLevel.locationWhileInUse) is always returning PermissionStatus.denied on Android 10 and doesn't respect granted permissions.

screenshot_20191020-191001

Describe the feature

Utilize LocationPermissionLevel enum on the Android platform

Platforms affected (mark all that apply)

  • πŸ“± iOS
  • πŸ€– Android

[android] "Can request only one set of permissions at a time."

πŸ› Bug Report

Calling await LocationPermissions().requestPermissions(); with both "Fine" and "Coarse" permission in AndroidManifest.xml gives the Can request only one set of permissions at a time. in the logs. Also, giving PermissionStatus.denied (even if approved) when checkPermissions called after awaiting requestPermissions.

Expected behaviour

The error/warning should not come in and correct status should be returned by checkPermissions after requestPermissions is called.

Reproduction steps

Code to reproduce:

  Future<bool> _checkLocationPermission() async {
    final checkPermission = await LocationPermissions().checkPermissionStatus();
    printIfDebug("checkPermission: $checkPermission");
    if (checkPermission == PermissionStatus.granted ||
        checkPermission == PermissionStatus.restricted) return true;
    return false;
  }

  Future<bool> _checkAndRequestLocationPermission() async {
    // return true, if already have permission
    if (await _checkLocationPermission()) return true;

    // request permission
    final _ = await LocationPermissions().requestPermissions();
    printIfDebug("requestPermission: $_");

    // check if permission was given
    final hasPermission = await _checkLocationPermission();

    // if no permission and "showShowPermissionRationale" then go to settings and return false
    if (!hasPermission &&
        await LocationPermissions().shouldShowRequestPermissionRationale()) {
      // if shouldRequest false, then open app settings and return false
      // TODO UI that shows why this permission is required
      await LocationPermissions().openAppSettings();
      return false;
    }

    return hasPermission;
  }

This is how it it is used for checking access for location before calling WifiManager.startScan api on android

  Future<List<WifiNetwork>> scanWifi() async {
    if (await _checkAndRequestLocationPermission())
      return await WiFiForIoTPlugin.loadWifiList();
    return null;
  }

Configuration

Android SDK: 28

Version: ^3.0.0

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Method requestPermissions returns inconsistent results with "Allow Once" on iOS

πŸ› Bug Report

The method requestPermissions() when called with the default permission level LocationPermissionLevel.location returns PermissionStatus.denied if the user selects "Allow Once", but if you call the same requestPermissions() again it will return PermissionStatus.granted.

This does not happen if you call requestPermissions() with the permission level LocationPermissionLevel.locationWhenInUse.

Expected behavior

The method should return PermissionStatus.granted on the first call and consecutive calls.

Reproduction steps

  • Set permission as denied on iOS
  • Call permissionRequestResult = await LocationPermissions().requestPermissions()
  • Select "Allow Once" on iOS modal
  • Check permissionRequestResult will equal to PermissionStatus.denied
  • Again, call permissionRequestResult = await LocationPermissions().requestPermissions()
  • Check permissionRequestResult will equal to PermissionStatus.granted

Configuration

Version: 3.0.0+1

Platform:

  • πŸ“± iOS
  • πŸ€– Android

Location permission level has no effect on checking or requesting permissions.

πŸ› Bug Report

This bug has two wrong behaviors:

First: When checking for location permission status using the permission level parameter, the results are always the same independently of the permission level passed as parameter.

Second: If your project requires permission for always, the systems return denied for all permission levels if you have not granted the always permission. It doesn't differentiate the WhenInUse for the WhenInUse level.

It seems that it is missing the capability to return the propper permission status when "While In Use" is granted. Even if the query (check) is using the LocationPermissionLevel.locationWhenInUse is used in the method call.

Expected behavior

I understand that the correct behavior would be to return the proper permission granted for permission level checked.

Reproduction steps

You can use the sample application to reproduce the error.
I'm running the tests in a Nexus 4 API 29 emulator.

Check the sequences below to reproduce the error:

Screen Shot 2020-05-24 at 11 51 15 AM
Screen Shot 2020-05-24 at 11 51 12 AM
Screen Shot 2020-05-24 at 11 51 08 AM

Configuration

My AndroidManifest.xml has the following lines:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

My build.gradle is set for:

compileSdkVersion 29
...
targetSdkVersion 29

Version: 2.0.5

Platform:

  • πŸ“± iOS
  • πŸ€– Android

iOS PermissionLevel enum wrong

The permission level enum is mixed up:
iOS:
typedef NS_ENUM(int, PermissionLevel) {
PermissionLevelLocation = 0,
PermissionLevelLocationAlways, # == 1
PermissionLevelLocationWhenInUse, # == 2
};

dart:
enum LocationPermissionLevel {
location, # == 0
locationWhenInUse, # == 1
locationAlways, # == 2
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.