Skip to content

iOS: Cannot request location always if we already have location when in use permission #490

@tallpants

Description

@tallpants

Bug report

If we have location when in use permission, requesting location always permission always returns denied, probably because of this line: https://github.com/react-native-community/react-native-permissions/blob/4017cbf0861b562bb48888f76cfa7c9a62c68ffc/ios/LocationAlways/RNPermissionHandlerLocationAlways.m#L38

Apple's documentation is pretty clear about how you're allowed to call requestAlwaysAuthorization if the current authorization status is either kCLAuthorizationStatusNotDetermined or kCLAuthorizationStatusAuthorizedWhenInUse. Calling this when we already have when-in-use authorization will prompt the user to upgrade to "always allow" location permissions.

But in the library we're assuming that if we currently have when-in-use authorization, we're not allowed to ask for always authorization.

I tested by manually calling requestAlwaysAuthorization in Objective-C after getting when-in-use authorization from react-native-permissions -- and the upgrade prompt shows up just fine.

This should be an easy fix (as far as I can tell).

Documentation for requestAlwaysAuthorization that explains this: https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization?changes=latest_minor&language=objc

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