Baseflow / flutter-permission-plugins

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.
https://baseflow.com
MIT License
52 stars 34 forks source link

Add permissions levels on Android #21

Closed formatCvt closed 4 years ago

formatCvt commented 4 years ago

🚀 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)

mvanbeusekom commented 4 years ago

This is an interesting feature which we should implement. Official documentation can be found here: https://developer.android.com/about/versions/10/privacy/changes#app-access-device-location

formatCvt commented 4 years ago

any news?

StijnWoerkom commented 4 years ago

@formatCvt Been working on this a few days now and can say you might see something at the end of the week.

formatCvt commented 4 years ago

@StijnWoerkom Awesome! Thanks!

formatCvt commented 4 years ago

any news?

StijnWoerkom commented 4 years ago

@formatCvt The LocationPermissionLevel respects now granted permissions, but until I am done with the whole update there is nothing available yet. I will make a push request when I'm done and I will let you know.

StijnWoerkom commented 4 years ago

Pull request is out for code review. I Will let you know when the new features are available.

daka-kolp commented 4 years ago

Any progress here?

StijnWoerkom commented 4 years ago

Still working on the pull-request. Some things need a bit more attention before we are able to push the new updates to the master branch.

DenisBogatirov commented 4 years ago

Still working on the pull-request. Some things need a bit more attention before we are able to push the new updates to the master branch.

Any updates?

StijnWoerkom commented 4 years ago

Working on final touches since the pull request missed some important points. I am trying to release an update this week. I will let you know when there is something available.

Vurarddo commented 4 years ago

Any news?

jovanovski commented 4 years ago

Guys, any updates?

StijnWoerkom commented 4 years ago

Today I am releasing an update on previous pull-request. I will let you know when the code is reviewed and when there is an update available.

StijnWoerkom commented 4 years ago

@formatCvt The Permissions Plugin has permission requests for foreground and background permissions. Google changed its regulations for the permissions in Android 10. For your case, you should involve the background permissions in your manifest. We have made the plugin compatible with the background location access.

(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION))

mvanbeusekom commented 4 years ago

Here a little bit more detailed information, this issue is supported since the last official version of the plugin. Depending on what you have listed in your AndroidManifest.xml file you can request permissions to access location services.

Depending on the supplied enum value you request the following permissions:

DenisBogatirov commented 4 years ago
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" />
mvanbeusekom commented 4 years ago

@DenisBogatirov I have created a new issue (#29 ) for your request. Hopefully we can continue the discussion there.

Nashkim254 commented 4 years ago

i get this error when i run my flutter app using geolocator and googlemaps

Launching lib\main.dart on TECNO K7 in debug mode... Running Gradle task 'assembleDebug'... C:\Program Files\flutter.pub-cache\hosted\pub.dartlang.org\location_permissions-2.0.5\android\src\main\java\com\baseflow\location_permissions\LocationPermissionsPlugin.java:284: error: cannot find symbol || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION)); ^ symbol: variable Q location: class VERSION_CODES C:\Program Files\flutter.pub-cache\hosted\pub.dartlang.org\location_permissions-2.0.5\android\src\main\java\com\baseflow\location_permissions\LocationPermissionsPlugin.java:284: error: cannot find symbol || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION)); ^ symbol: variable ACCESS_BACKGROUND_LOCATION location: class permission C:\Program Files\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 C:\Program Files\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 C:\Program Files\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.

BUILD FAILED in 4m 8s Finished with error: Gradle task assembleDebug failed with exit code 1

bikashKatwal commented 4 years ago

Is there any updates on why app on "Allowed Only While in Use " gives GeolocationStatus.denied

Nashkim254 commented 4 years ago

I think its because am using android 10 SDK plugin to build my app ...and there was breaking changes on location on android 10 api 29

On Apr 9, 2020 14:15, "Bikash Katwal" notifications@github.com wrote:

Is there any updates on why app on "Allowed Only While in Use " gives GeolocationStatus.denied

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-plugins/issues/21#issuecomment-611473116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGI4AZXXGW6IINPB6HGO7HTRLWU6LANCNFSM4JCVB3FQ .