expo-permissions - Error: Unrecognized persmission: location

1.1k views Asked by At

It's a bare reacts native project.

Code I'm using:

import * as unimodules from 'react-native-unimodules';
// ...
    unimodules.Permissions.getAsync(unimodules.Permissions.LOCATION)
      .then(console.info)
      .catch(console.error)

; version in package.json

"react-native-unimodules": "^0.7.0",

in yarn.lock

expo-permissions@~8.0.0:
  version "8.0.0"
  resolved "https://registry.yarnpkg.com/expo-permissions/-/expo-permissions-8.0.0.tgz#5a45e8451dd7ff37c9e6ce5e2447818372547813"
  integrity sha512-GHTRmwh1rd1b0FcibluPFu93NNQyl9b1anBBDVPmomoo9Prz7kDcO5p2hFqM99r896yvAUSe0fPloPKUq4g/1A==
save error about some other permission type (Permissions.NOTIFICATIONS works fine, while Permissions.CAMERA does not)

So I started checking the code. List of permissions is defined here

seems that error is from here https://github.com/expo/expo/blob/master/packages/expo-permissions/ios/EXPermissions/EXPermissions.m#L69

https://github.com/expo/expo/blob/master/packages/expo-permissions/src/Permissions.ts#L28 . It a list.

However here https://github.com/expo/expo/blob/master/packages/expo-permissions/ios/EXPermissions/EXPermissions.m#L58 I see that

  [self registerRequesters:@[userNotificationRequester, remoteNotificationRequester]];

is called only for notifications. So that code means that getAsync works only for Notifications. Is it true? I even don't understand how to report this question to expo team.

PS My environment:

  Expo CLI 3.11.3 environment info:
System:
  OS: macOS 10.14.6
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 12.14.0 - ~/.config/nvm/12.14.0/bin/node
  Yarn: 1.21.1 - /usr/local/bin/yarn
  npm: 6.13.4 - ~/.config/nvm/12.14.0/bin/npm
  Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
  Android Studio: 3.5 AI-191.8026.42.35.6010548
  Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
  @types/react-native: ^0.60.22 => 0.60.22
  react: 16.9.0 => 16.9.0
  react-native: 0.61.5 => 0.61.5
  react-navigation: ^4.0.10 => 4.0.10
npmGlobalPackages:
  expo-cli: 3.11.3
1

There are 1 answers

0
Vasiliy vvscode Vanchuk On

Ok. Strange that it's not descovered in documentation.

That registerRequesters is called from other expo-modules. So to use location permissions request I have to install expo-location. That module registeres requester here:

https://github.com/expo/expo/blob/8b45846976d16b28329bd5fb067040c16db50089/packages/expo-location/ios/EXLocation/EXLocation.m#L63

Seems same about other modules, if you face similar issue