Код: Выделить всё
Future _requestLocationPermission() async {
// Check if location services are enabled
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled
return;
}
PermissionStatus status = await Permission.location.request();
// Step 2: Check permission status
//PermissionStatus status = await Permission.location.status;
if (status.isGranted) {
print("Permission granted");
_getCurrentLocation();
} else if (status.isDenied) {
print("Permission denied");
} else if (status.isPermanentlyDenied) {
print("Permission Permanently denied");
}
}
< /code>
И, как это было предложено в качестве предпосылки, как, некоторые строки должны быть включены в файл info.plist, которые являются: < /p>
NSLocationWhenInUseUsageDescription
This app needs location access while using the app.
NSLocationAlwaysUsageDescription
This app needs location access at all times.
NSLocationAlwaysAndWhenInUseUsageDescription
This app needs location access always and when in use.
UIBackgroundModes
location
После выполнения этого выше, я не смог открыть всплывающее окно разрешение для местоположения. https://stackoverflow.com/a/68600411/5034193
, который говорит, что разрешения на iOS отключены по умолчанию, и у вас есть набор правильного gcc_preprocessor_definition был 'разрешение_локации = 1' и не писал для других разрешений. Потому что другие разрешения, такие как разрешение на хранение, уведомление и т. Д., работают нормально. Podfile?>
Подробнее здесь: https://stackoverflow.com/questions/797 ... ion-in-ios
Мобильная версия