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

iOS - Location permission dialog is not appearing and always giving denied response. #39

Closed ravitejaavv closed 4 years ago

ravitejaavv commented 4 years ago
  final PermissionStatus permissionRequestResult = await LocationPermissions()
        .requestPermissions();
    if(permissionRequestResult == PermissionStatus.granted){
      onGranted();
    }else{
      onDenied();
    }

always executing onDenied() function

Version: 2.0.5

Platform:

mvanbeusekom commented 4 years ago

@ravitejaavv have you listed all the required permissions in your Info.plist file?

You should add the following lines to your ios/Runner/info.plist file (of course you provide more user friendly messages as part of the tags):

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Need location when in use</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Always and when in use!</string>
    <key>NSLocationUsageDescription</key>
    <string>Older devices need location.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Can I haz location always?</string>

Check out the Info.plist file in the example project here

ravitejaavv commented 4 years ago

@ravitejaavv have you listed all the required permissions in your Info.plist file?

You should add the following lines to your ios/Runner/info.plist file (of course you provide more user friendly messages as part of the tags):

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Need location when in use</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Always and when in use!</string>
    <key>NSLocationUsageDescription</key>
    <string>Older devices need location.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Can I haz location always?</string>

Check out the Info.plist file in the example project here

i have added only 2 permissions earlier. Its working fine now after adding all permissions

sanju-developer commented 4 years ago

@ravitejaavv

I'm testing on emulator and I set my permission to Never from the setting of emulator. then I have added all the permission as you stated, but this will not opening that dialog.

Could please tell what would be the issue ? 🙃

mvanbeusekom commented 4 years ago

@sanju-developer Setting the permissions to Never means never ask me again for permissions. So it makes sense you don’t receive a dialog.

sanju-developer commented 4 years ago

@mvanbeusekom You are correct.

Do you know any way to direct open location page in mobile setting from an flutter app ?

mvanbeusekom commented 4 years ago

On iOS you can only open the App settings page. Other direct links are not allowed by Apple. On Android there are some more options but these are not yet supported by the location_permissions plug-in.

To open the app settings you can use the openAppSettings method of this plugin.

sanju-developer commented 4 years ago

@mvanbeusekom ,

Okay cool, Thanks for sharing knowledge. I really don't know that apple don't allow to open direct link.

Ya for android I'm using

openAppSettings

BTW, then how Google Map, Ola and all open direct location page form their App.🧐

mvanbeusekom commented 4 years ago

I don’t know how they do it, if you have any documentation or information I would gladly have a look at it and see if it fits in the plugin

sanju-developer commented 4 years ago

Ya, I'm already struggling with it. If I find something surely will come back to you.