Permissions Setup
This guide covers the required permissions for both iOS and Android platforms to use Lazarillo Maps Flutter.
📱 iOS Permissions
Required Permissions
Add the following permissions to your ios/Runner/Info.plist file:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location to provide navigation and location-based services.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location to provide navigation and location-based services.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location to provide navigation and location-based services.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to detect nearby beacons for indoor navigation.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth to detect nearby beacons for indoor navigation.</string>Optional Permissions
For enhanced functionality, you may also want to add:
<key>NSCameraUsageDescription</key>
<string>This app uses the camera for augmented reality features.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone for voice navigation features.</string>Background Modes
For background location updates, add to your Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>location</string>
<string>bluetooth-central</string>
</array>🤖 Android Permissions
Required Permissions
Add the following permissions to your android/app/src/main/AndroidManifest.xml file:
<!-- Location permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Bluetooth permissions for Android 12+ -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Legacy Bluetooth permissions for Android < 12 -->
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- Notification permission for Android 13+ -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- Activity recognition for better location accuracy -->
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />Feature Declarations
Add these feature declarations to your AndroidManifest.xml:
<uses-feature android:name="android.hardware.location" android:required="true" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />🔧 Runtime Permission Handling
iOS
iOS handles permissions automatically. The system will prompt users when the app first requests location or Bluetooth access.
Android
For Android, you need to request permissions at runtime. Here’s an example:
import 'package:permission_handler/permission_handler.dart';
Future<void> requestPermissions() async {
// Request location permissions
await Permission.location.request();
await Permission.locationAlways.request();
// Request Bluetooth permissions
await Permission.bluetooth.request();
await Permission.bluetoothScan.request();
await Permission.bluetoothConnect.request();
// Request notification permission for Android 13+
if (await Permission.notification.isDenied) {
await Permission.notification.request();
}
}📋 Permission Status Check
You can check permission status using:
import 'package:permission_handler/permission_handler.dart';
Future<void> checkPermissions() async {
// Check location permission
if (await Permission.location.isGranted) {
print('Location permission granted');
} else {
print('Location permission denied');
}
// Check Bluetooth permission
if (await Permission.bluetooth.isGranted) {
print('Bluetooth permission granted');
} else {
print('Bluetooth permission denied');
}
}⚠️ Important Notes
iOS
- Location permissions are required for navigation functionality
- Bluetooth permissions are required for indoor navigation with beacons
- Users can deny permissions, so handle gracefully in your app
Android
- Location permissions are required for navigation functionality
- Bluetooth permissions are required for indoor navigation with beacons
- Android 12+ requires separate Bluetooth scan and connect permissions
- Android 13+ requires notification permission for location updates
🆘 Troubleshooting
Common Issues
-
Location not working on iOS:
- Check that
NSLocationWhenInUseUsageDescriptionis set in Info.plist - Ensure location services are enabled in device settings
- Check that
-
Bluetooth not working on Android:
- Check that Bluetooth permissions are properly declared
- For Android 12+, ensure
BLUETOOTH_SCANandBLUETOOTH_CONNECTare requested
-
Background location not working:
- Ensure background modes are properly configured in iOS
- Check that location permission is set to “Always” in device settings
Testing Permissions
You can test permissions using the example app:
// Test location permission
final locationStatus = await Permission.location.status;
print('Location status: $locationStatus');
// Test Bluetooth permission
final bluetoothStatus = await Permission.bluetooth.status;
print('Bluetooth status: $bluetoothStatus');For more information, see the permission_handler package documentation.