0

I'm having a problem in location permission prompt in MIUI 12.1.4 Android 11. It is not showing if there's PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION. Also, I console log the result and it gave me this ... android.permission.ACCESS_BACKGROUND_LOCATION": "denied", "android.permission.ACCESS_FINE_LOCATION": "never_ask_again"}

Here's my code ...

 const granted = systemVersion > 9 ? await PermissionsAndroid.requestMultiple([
        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
        PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,
      ]) : await PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION ])

When I remove the PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION the location permission shows but doesn't have "Allow all the time" option. How to resolve this issue? Thank you!

carch
  • 217
  • 4
  • 18

1 Answers1

1

Even if you add ACCESS_BACKGROUND_LOCATION to the list of the permissions to request, the system will ignore it. If the application needs to use location in the background. To do that, you have to prepare your own dialog with an explicit message explaining the use of background location. When the user agrees, take him to the application’s settings page where he can choose the level of permission he wants to grant.

Read This Article For More Details

Sreehari K
  • 887
  • 6
  • 16
  • Hi, thank you for your answer. Can you help me on how to modify the title and message on my dialog permission? const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, { 'title': 'ReactNativeCode Location Permission', 'message': 'ReactNativeCode App needs access to your location ' } ) I tried this but the dialog content does not change – carch May 06 '21 at 08:45
  • I don't know how this works on RN, can you please check this repo https://github.com/zoontek/react-native-permissions/issues/435 – Sreehari K May 06 '21 at 09:57