flutterlocation
flutterlocation copied to clipboard
fix: Location service prompt not working on iOS 16
I have tried the same code as mention below and it's works fine on both Android and iOS (version below 16).
Location location = new Location();
bool _serviceEnabled; PermissionStatus _permissionGranted; LocationData _locationData;
_serviceEnabled = await location.serviceEnabled(); if (!_serviceEnabled) { _serviceEnabled = await location.requestService(); if (!_serviceEnabled) { return; } }
_permissionGranted = await location.hasPermission(); if (_permissionGranted == PermissionStatus.denied) { _permissionGranted = await location.requestPermission(); if (_permissionGranted != PermissionStatus.granted) { return; } }
_locationData = await location.getLocation();
- location.serviceEnabled() is not working on iOS 16
if you remove the background location from the info.plist it will work, don't ask why!