Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking permission for iOS LOCATION_ALWAYS and LOCATION_WHEN_IN_USE return as "granted" #730

Closed
m2jobe opened this issue Oct 25, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@m2jobe
Copy link

m2jobe commented Oct 25, 2022

Bug summary

We are seeing a bug where when we request request(Permissions.PERMISSIONS.IOS.LOCATION_ALWAYS) and we see the popup below. Upon selecting Allow while using app (LOCATION_WHEN_IN_USE), if we then check both the permissions LOCATION_ALWAYS and LOCATION_WHEN_IN_USE, they return as granted. The expected behaviour from this flow would be that LOCATION_ALWAYS is denied and only LOCATION_WHEN_IN_USE is marked as granted
Screen Shot 2022-10-25 at 5 02 19 PM

In suspecting that this may be related to: #490

I am investigating going through the "A normal permission escalation" as outlined here.

Screen Shot 2022-10-25 at 5 05 20 PM

Library version

3.3.1

Environment info

System:
    OS: macOS 12.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 108.70 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.7.0/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/muhammedjobe/.rvm/rubies/ruby-3.0.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8815526
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 15.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.1 => 0.68.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found


### Steps to reproduce

1. Request ios location always permissions
2. checkMultiple permissions for ios location always and location when in use (both should appear as granted)


### Reproducible sample code

```js
request(Permissions.PERMISSIONS.IOS.LOCATION_ALWAYS).then(
    permissionResult => {
      if (permissionResult !== Permissions.RESULTS.GRANTED) {
        console.log("failed on both back and fore");
      } else {
        checkMultiple([
          PERMISSIONS.IOS.LOCATION_ALWAYS,
          PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
        ]).then(statuses => {
          console.log(
            "LOCATION_ALWAYS",
            statuses[PERMISSIONS.IOS.LOCATION_ALWAYS],
          );
          console.log(
            "LOCATION_WHEN_IN_USE",
            statuses[PERMISSIONS.IOS.LOCATION_WHEN_IN_USE],
          );
        });
      }
    },
  );
@m2jobe m2jobe added the bug Something isn't working label Oct 25, 2022
@zoontek zoontek closed this as completed Oct 25, 2022
@zoontek zoontek reopened this Oct 25, 2022
@zoontek
Copy link
Owner

zoontek commented Oct 25, 2022

This is normal, just how the iOS location permission works. See https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization (search for "Request Always Authorization Directly" in the page)

If your app’s current state is CLAuthorizationStatus.notDetermined and you call requestAlwaysAuthorization(), Core Location uses two prompts before it fully enables Always authorization.
The first prompt displays immediately with the string from NSLocationWhenInUseUsageDescription. The user prompt displays the following options, which determine the authorization your app receives:

Allow While Using App | Core Location grants your app a Provisional Always authorization. The delegate receives CLAuthorizationStatus.authorizedAlways.

And later, it will prompt a second time saying this app uses background location and the user will be able to change his mind.

@zoontek zoontek closed this as completed Oct 25, 2022
@zoontek
Copy link
Owner

zoontek commented Oct 25, 2022

@m2jobe
Copy link
Author

m2jobe commented Oct 26, 2022

Thank you @zoontek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants