[Help Wanted]: Precise location permission and "Allow all the time" permission pop up unasked.
Required Reading
- [x] Confirmed
Plugin Version
flutter_background_geolocation: "4.16.10"
Mobile operating-system(s)
- [ ] iOS
- [x] Android
Device Manufacturer(s) and Model(s)
One Plus Nord CE 5
Device operating-systems(s)
Oxygen OS 15
What do you require assistance about?
-
I have explicitly handled requesting permissions in my code, but the app pops up Location permission and "Allow all the time" permission notification unannounced.
-
This happens only when the app is installed from the play store (internal testing). This does not happen when installing debug/release version through USB.
My main.dart file looks like the one below.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
//configuration settings need to be updated at app open
await MobileLocationService.initConfigure();
// Set up background listeners
bg.BackgroundGeolocation.registerHeadlessTask(onBackgroundHeadlessEvent);
BackgroundFetch.registerHeadlessTask(onBackgroundFetch);
// Set up foreground listeners
bg.BackgroundGeolocation.onLocation(onForegroundLocation);
bg.BackgroundGeolocation.onHeartbeat(onForegroundHeartbeat);
runApp(const MyApp());
}
my mobile_location_service.dart looks like this
static Future<void> initConfigure() async {
if (_isConfigured) {
return MyLogger.print("initConfigure: MLS already configured, skipping");
}
// bg.BackgroundGeolocation.destroyLocations();
await bg.BackgroundGeolocation.ready(bg.Config(
desiredAccuracy: isIos() ? bg.Config.DESIRED_ACCURACY_NAVIGATION : bg.Config.DESIRED_ACCURACY_HIGH,
//battery heavy setting
distanceFilter: 0,
//battery heavy setting
disableStopDetection: true,
locationUpdateInterval: 60000,
stopOnTerminate: false,
startOnBoot: true,
foregroundService: true,
enableHeadless: true,
preventSuspend: true,
debug: MyConst.isDebugSettingsEnabled,
//let me handle the permsissiona
locationAuthorizationRequest: "Any",
//let me handle the permsissiona
disableLocationAuthorizationAlert: true,
notification: bg.Notification(
title: MyConst.appName,
text: "Background location tracking in progress.",
channelName: "Background Location",
// smallIcon: "mipmap/ic_launcher",
sticky: true,
priority: bg.Config.NOTIFICATION_PRIORITY_HIGH,
),
logLevel: MyConst.isDebugSettingsEnabled ? bg.Config.LOG_LEVEL_VERBOSE : bg.Config.LOG_LEVEL_INFO,
)).then((bg.State state) {
MyLogger.print("initConfigure: BG ready. ${state.toString()}");
});
_isConfigured = true;
}
Inspite of all these settings it is still showing up as shown above. Please resolve this issue.
[Optional] Plugin Code and/or Config
static Future<void> initConfigure() async {
if (_isConfigured) {
return MyLogger.print("initConfigure: MLS already configured, skipping");
}
// bg.BackgroundGeolocation.destroyLocations();
await bg.BackgroundGeolocation.ready(bg.Config(
desiredAccuracy: isIos() ? bg.Config.DESIRED_ACCURACY_NAVIGATION : bg.Config.DESIRED_ACCURACY_HIGH,
//battery heavy setting
distanceFilter: 0,
//battery heavy setting
disableStopDetection: true,
locationUpdateInterval: 60000,
stopOnTerminate: false,
startOnBoot: true,
foregroundService: true,
enableHeadless: true,
preventSuspend: true,
debug: MyConst.isDebugSettingsEnabled,
//let me handle the permsissiona
locationAuthorizationRequest: "Any",
//let me handle the permsissiona
disableLocationAuthorizationAlert: true,
notification: bg.Notification(
title: MyConst.appName,
text: "Background location tracking in progress.",
channelName: "Background Location",
// smallIcon: "mipmap/ic_launcher",
sticky: true,
priority: bg.Config.NOTIFICATION_PRIORITY_HIGH,
),
logLevel: MyConst.isDebugSettingsEnabled ? bg.Config.LOG_LEVEL_VERBOSE : bg.Config.LOG_LEVEL_INFO,
)).then((bg.State state) {
MyLogger.print("initConfigure: BG ready. ${state.toString()}");
});
_isConfigured = true;
}
[Optional] Relevant log output
Please provide logs of this occurring.
Also provide exact reproduction steps.
Screen recording of the occurrence https://github.com/user-attachments/assets/60559882-0ef8-4aa7-907f-377c0ade5111
Logs after_install.log
Calling await MobileLocationService.initConfigure(); and registering event listeners (eg .onLocation) should only be called *inside* MyApp`, not before it's instantiated.
The SDK does not request permission until you call .start().
You must not call any method which requires permission until .ready(config) has resolved (eg .getCurrentPosition).
Okay I'll change it the way you said but my main problem is this.
Why does occur ONLY in the version downloaded from the play store ? This does not occur in debug or even release versions while building and installing via usb from the mac
I've never heard of this before.
The only way the plug-in asks for permissions is when a method is called upon it that requires permissions (eg .start(), .getCurrentPosition, .requestPermission)
This issue is stale because it has been open for 30 days with no activity.