0

这是一个裸反应的原生项目。

我正在使用的代码:

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

; package.json 中的版本

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

在纱线锁

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)

所以我开始检查代码。权限列表在这里定义

似乎错误来自这里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。它是一个列表。

但是在这里https://github.com/expo/expo/blob/master/packages/expo-permissions/ios/EXPermissions/EXPermissions.m#L58我看到了

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

仅用于通知。因此,该代码意味着getAsync仅适用于Notifications. 这是真的吗?我什至不明白如何向世博团队报告这个问题。

PS我的环境:

  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
4

1 回答 1

0

好的。奇怪的是它没有在文档中发现。

registerRequesters是从其他博览会模块中调用的。所以要使用location权限请求,我必须安装expo-location. 该模块在此处注册请求者:

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

如果您遇到类似问题,其他模块似乎相同

于 2019-12-31T09:30:40.327 回答