Search code examples
iosflutterpermissions

Permission.locationAlways.isGranted always returns false ios


I am using the permission_handler package in flutter to access permissions of the underlying device that my app would run on.

My problem, however, is that the Permission.locationAlways.isGranted always returns false, even when I have changed the permission to "always allow" in the app settings.

Here's the function that checks the phone's permission using the permission_handler package:

void _checkLocationPermission() async {
  bool isGranted = await Permission.locationAlways.isGranted;
  print("isGranted -- $isGranted");
  if (_locationPermissionGranted != isGranted) {
    setState(() {
      _locationPermissionGranted = isGranted;
    });
  }
}

This function is called in the initState() method of the screen. I would appreciate any guidance to solve this; it seems pretty simple and I don't know what I am doing wrong.


Solution

  • Make sure you installed the package properly on ios. Modify the podfile appropriately as explained here: here. Also, this video may help, in case you're struggling with the instructions in the previous link: video