这是一个毫无反应的本地项目。
我正在使用的代码:
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",
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)
所以我开始检查代码。权限列表在此定义
https://github.com/expo/expo/blob/master/packages/expo-permissions/src/Permissions.ts#L28。它是一个列表。
[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
好奇怪的是它没有在文档中发现。
registerRequesters
是从其他expo模块调用的。因此,要使用location
权限请求,我必须安装expo-location
。该模块在此处注册请求者:
如果遇到类似的问题,其他模块似乎也一样