Detailed development guide for Android background location permission requests
As a detailed explanation of the contents described ahead, it includes development matters and other precautions when installing loplat SDK (v2.1.1.6.1 or higher).
1. Matters to be notified to users within the app
- Disclosure of background location information access:
- (Solution 1) The app itself can implement 'Location Permission-Allow all the time'
- (Solution 1) The app itself can implement 'Location Permission-Allow all the time'
In the case of implementing on your own and unless ‘Allow all the time’ is selected in Android 11 or higher, location information can be collected only when the app is being used. This may cause issues with collecting location information continuously, as before. In addition, you must directly implement the UI for review and additional permission request logic suitable for the current location permission level by referring to the contents of Solution 2.
To disable the allow-all-the-time prompt provided by loplat, Plengi.disableFeatureBgLocationReviewUX(true)
must be declared in Application.onCreate() as shown below.
- Java
- Kotlin
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
Plengi plengi = Plengi.getInstance(context);
plengi.disableFeatureBgLocationReviewUX(true);
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
val plengi = Plengi.getInstance(context)
plengi.disableFeatureBgLocationReviewUX(true)
- (Solution 2) (Recommended) You can obtain 'Location Permission-Allow all the time' by using 'Location Permission-Allow all the time' provided by loplat SDK.
Solution 2 includes a response to continuous location collection, even in Android 11. Even if the user is using the app for location permission, you can encourage Location Permission-Allow all the time through the explanation. Even if the user does not always allow the location permission, continuous location collection is possible just by dismissing the notification. In addition, it provides an API to add the UI necessary for screening easily, and Prompt that requests location permission has been implemented depending on the situation.
loplat SDK ‘Location Permission-Allow all the time Prompt’
Description of each prompt details and customization methods when applying Solution 2
Prompt 1. loplat SDK sends out a notification about background location permission access as below.
- You must call
Plengi.setDefaultNotificationInfo
to change the Icon, Tile (Notification based on location service), and Text (Tap to set up this notification). The app name in the notification is loplat SDK, not loplat.
- Java
- Kotlin
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
Plengi plengi = Plengi.getInstance(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setDefaultNotificationInfo(
R.drawable.noti_small_icon,
R.string.noti_title,
R.string.noti_text
);
}
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
val plengi = Plengi.getInstance(context)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setDefaultNotificationInfo(
R.drawable.noti_small_icon,
R.string.noti_title,
R.string.noti_text
)
}
- To customize the notification itself, create the notification to use and then call
Plengi.setDefaultNotificationInfo()
.
- Java
- Kotlin
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
// Customizing the entire flow, starting with notifications
Intent intent = new Intent(context, Activity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
Plengi plengi = Plengi.getInstance(context);
/* The value of the second parameter of NotificationCompat.Builder must be
Please use Plengi.getDefaultNotificationChannelId(). */
Notification notification = new NotificationCompat.Builder(this, plengi.getDefaultNotificationChannelId())
.setContentTitle("Notification Title")
.setContentText("Notification Content")
...
.build();
plengi.setDefaultNotificationInfo(notification);
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
// Customizing the entire flow, starting with notifications
val intent = Intent(context: Context, Activity.class)
val contentIntent = PendingIntent.getActivity(this, 0, intent, 0)
val plengi = Plengi.getInstance(context)
/* The value of the second parameter of NotificationCompat.Builder must be
Please use Plengi.getDefaultNotificationChannelId(). */
val notification = NotificationCompat.Builder(this, plengi.getDefaultNotificationChannelId())
.setContentTitle("Notification title")
.setContentText("Notification Content")
...
.build()
plengi.setDefaultNotificationInfo(notification)
Prompt 2. The following screen is displayed if you click the notification about background location permission access created by loplat SDK.
- If you click the ‘Change location permission’ button, a dialog box for Disclosure of background location information access details. Disclosure of background location information access contents is displayed.
- If notifications are turned OFF by changing the notification settings, users with Android 11 ‘Location permission-Only this time’ can always obtain the location.
- If you want to change the message of the dialog box (location-based according to Android policy ... You can disable notifications in settings), you must call
Plengi.setDefaultNotificationChannel()
.
- Java
- Kotlin
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
Plengi plengi = Plengi.getInstance(context);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setDefaultNotificationChannel(
// 0 to use default value of Loplat SDK
R.string.channel_name,
// 0 to use default value of Loplat SDK
R.string.channel_description,
// 0 to use default value of Loplat SDK
R.string.guide_description
);
}
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
val plengi = Plengi.getInstance(context)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setDefaultNotificationChannel(
// 0 to use default value of Loplat SDK
R.string.channel_name,
// 0 to use default value of Loplat SDK
R.string.channel_description,
// 0 to use default value of Loplat SDK
R.string.guide_description
)
}
Prompt 3. Displays a dialog box for disclosing background location information access details, as shown below.
Default dialog | Custom Layout Dialog |
---|---|
- If you want to use
Custom Layout
rather than the default dialog provided by loplat SDK, you must declarePlengi.setBackgroundLocationAccessDialogLayout()
in Application.onCreate() as below.
- Java
- Kotlin
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
Plengi plengi = Plengi.getInstance(context);
// Prompt dialog layout for background location examine
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setBackgroundLocationAccessDialogLayout(R.layout.custom_dialog)
}
// Plengi configuration APIs (custom notification configuration, PlengiListener) must be called in Application.onCreate().
val plengi = Plengi.getInstance(context)
// Prompt dialog layout for background location examine
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
plengi.setBackgroundLocationAccessDialogLayout(R.layout.custom_dialog)
}
- When using
Custom Layout
, the aboveCustom Layout
dialog box is displayed. You canset
Layout
except for the "Cancel/OK" button. Images are not required, and in the case of our CashPlace app, we added them to improve readability. - In the case of using
Custom Layout
, the following elements must be included in the text. 1. The term 'Location' 2. Use one of 'background'/'when the app is closed'/'Allow all the time'/'when the app is not in use to indicate that the usage is in the background ex) "Even when you are not using this app" 3. List all features that use location in the background ex) "To inform users of benefits available nearby" 4. If you extend your permissible use to advertising, you must include the following statement: 'This data is also used to provide advertisements/support advertisement functions/support advertisements.' ex) "This data is also used to serve advertisements."
Prompt 4. Request background location permission.
2. What needs to be explained in the Google Play Store
Indicate background location information access in Google Play Store app information:
- Background location access must be indicated in the app description.
ex) CashPlace collects location data even when the app is closed or not in use to provide store information collection guidance and offer notifications based on the user's current location. This data is also used to support advertising.
- App screenshots related to background location access should be added to phone screenshots.
3. To be provided for review on Google Play
Providing demo video:
- Demo video should include all of the items below.
- Runtime Prompt
- Explicit in-app public background location permission access dialog displayed to the user
- Features that are active in the background (Campaign feature of loplat X)
- Recommended video length is 30 seconds or less. YouTube links are the preferred video format, but cloud storage links to mp4 or other common video file formats are also supported. (Our CashPlace demo video)
Google Play Console → Main Menu → Policies > App Contents → Sensitive Permissions and APIs → Management → Location Information Access Permissions:
-
In this setting, the screening will be based on the policy compliance selection. If you set ‘No’, you can update the app as before the review within the approval schedule, regardless of whether background location permission is accessed. If you set 'Yes' to proceed with the review, you must provide answers to the questions below and a link to a demo video.
-
You must answer two questions.
-
What is the main purpose?
Example answer: CashPlace uses geofencing to provide various benefits and advertisements based on the user's current location and collects data from stores around the user, such as convenience stores, cafes, restaurants, etc. It is an app that provides a particular reward every time. To use CashPlace, you must have an account on KakaoTalk and be located in Korea. Users can enter the desired store near their current location and take two photos in the center of the store to complete the collection. -
Why do apps need background location access?
Example answer: The CashPlace application periodically checks the user's location like geofencing, recognizes whether a particular store has been visited, and provides the user with benefits or advertisements suitable for that store. For example, even when CashPlace users are not using the app, when they enter a store of a particular brand, they are notified of point products that can be used in that store or ongoing events or events. Even when the CashPlace app is not used, permission to access background location information is required to provide accurate benefits and advertisements tailored to the user's location.
-
-
Add a link to the demo video.
If your app has a login screen and you want the crawler to test the login process or the content presented after login, you need to provide account credentials.
- Reference: Credentials can only be automatically inserted into Android apps using standard Android widgets. Credentials are unavailable for apps that use OpenGL to render custom controls or WebView as a web-based authentication mechanism.
Reference
Prompt for ‘Location-keep and never ask again’ permission
If the user selects the "Keep it up and never ask again" permission when requesting the 'Location-Allow all the time' permission, it is exception-processed to guide the user to go to the app's settings screen in situations where the 'Location-Allow all the time' permission is required.