Reputation: 69
I am building a food delivery app in flutter, where it contains seller side, user side and driver side. The app contains live tracking feature, which requires background location permission. But this leads to the rejection of the app. The foreground service location permission is required for android 14 to work for the background location.
This is the mail for rejection reason which I got from google.:
Issue found: Background location access not declared
We detected that your app contains at least one feature that requests access to location in the background, however your permission declaration form did not reflect this. Please log in to your Play Console to resubmit your location declaration form. You may either remove location in the background from your app or indicate that the usage is in the background.Issue details
We found an issue in the following area(s):
Version code 26
About the Permissions and APIs that Access Sensitive Information policy
Requests for permission and APIs that access sensitive information should make sense to users. You may only request permissions and APIs that access sensitive information that are necessary to implement critical current features or services in your app that are promoted in your Google Play listing. You may not use permissions or APIs that access sensitive information that give access to user or device data for undisclosed, unimplemented, or disallowed features or purposes. Personal or sensitive data accessed through permissions or APIs that access sensitive information may never be sold nor shared for a purpose facilitating sale.Request permissions and APIs that access sensitive information to access data in context (via incremental requests), so that users understand why your app is requesting the permission. Use the data only for purposes that the user has consented to. If you later wish to use the data for other purposes, you must ask users and make sure they affirmatively agree to the additional uses.*
This is my manifest.xml where all the location related permission is mentioned.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
Now How can I make the app approve? I am using Location package.
Future<void> _listenLocation() async {
model.location.enableBackgroundMode(enable: true);
locationStream = model.location.onLocationChanged.listen((event) async {
logger.w("Is it Working.....");
await FirebaseFirestore.instance
.collection('location')
.doc(widget.orderId.toString())
.set({
'latitude': event.latitude,
'longitude': event.longitude,
'dishOrderId': widget.orderId.toString()
}, SetOptions(merge: true));
});
}
This function is require for continuous updating of Driver location when the app is in background and google map is opened. But the catch is the location permission is in all time. Please tell me way to fix.
This is the message what we are passing for getting the background location permission in dialog box:
We need your permission to track your device's location for accurate delivery of order. You can manage this permission in your device settings at any time.
This is the video link which we added to play console:
https://www.youtube.com/shorts/6X3VeCxIcfQ
I have tried follow youtube videos to make the live tracking work but this requires background location. I don't find any way to make the live tracking work with foreground location only in flutter. any help will be appreciated.
Upvotes: 0
Views: 270
Reputation: 66
I think, you dont need ACCESS_BACKGROUND_LOCATION
permission.
I assume, you use something like flutter_foreground_task
or pigeon
for fetching location in an android foreground service.
Your foreground serivce location fetching does NOT count as background.
ACCESS_BACKGROUND_LOCATION
is created for WorkManagers/Alarm to do it actually in background when app was not even launched. Foreground services launched from the app don't need this permission.
So, if driver presses "GO" button and you start a service with a notification it counts as foreground.
https://developer.android.com/develop/sensors-and-location/location/background
Permissions you should use
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
Here is also a sample of foreground location. https://pub.dev/packages/flutter_foreground_task
Upvotes: 0