Skip to content

Can't ask for always authorization after a location is requested #16

@ricsantos

Description

@ricsantos

Similar to #4 but with a nuance.

In iOS 11, it is advised to first ask the user for whenInUse location authorization, and then at a later time upgrade that to always authorization.

Using PromiseKit/CoreLocation 6.2.5, the request for always will fail to return if whileInUse has been granted and a location has been requested.

Here is a small chain that demonstrates the issue:

_ = firstly {
    CLLocationManager.requestAuthorization(type: .whenInUse)
}.then { _ in
    CLLocationManager.requestLocation()
}.then { _ in
    CLLocationManager.requestAuthorization(type: .always)
}.done { _ in
    print("tada")
}

In order to test this in a project, the usage description keys will need to be added to the Info.plist file:

<key>NSLocationWhenInUseUsageDescription</key>
<string>When In Use</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Always</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Always and When In Use</string>

Running that promise, the log tada is never printed. By removing the requestLocation promise from the chain, it all works as expected.

I also have a small demo project reproducing this, I can supply if that helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions