Skip to content

How to request both ACCESS_BACKGROUND_LOCATION and ACCESS_FINE_LOCATION #435

@eliaslecomte

Description

@eliaslecomte

Question

With Android 10, you can request location access in the foreground or in the background.
According the Android documentation (https://developer.android.com/training/location/request-updates), you can request them at the same time:

ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION),

This results in a permission request dialog with 3 options (all the time, only when in app, deny).

How to do this with react-native-permissions?
The only option I see is to first request ACCESS_FINE_LOCATION and then ACCESS_BACKGROUND_LOCATION but this requests in the user having to approve twice :-(.

So the only option now is:
const locationResult = await request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION); const backgroundResult = await request(PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions