我已经尝试了大多数问题的结果,但没有一个对我有用。我尝试使用 PermissionAndroid.request 方法访问 WRITE_EXTERNAL_STORAGE 权限,但它总是返回 never_ask_again 作为结果。
我的请求文件:
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
{
title: 'External Storage Write Permission',
message: 'App needs write permission',
},
);
console.log(granted);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
// Start downloading
downloadFile();
console.log('Storage Permission Granted.');
} else {
// If permission denied then show alert
Alert.alert('Error', 'Storage Permission Not Granted');
}
} catch (err) {
// To handle permission related exception
console.log('++++' + err);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 AndroidManifest.xml 文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" …
Run Code Online (Sandbox Code Playgroud) android android-external-storage react-native react-native-permissions
我是 Expo 的新手,我不知道这里有什么问题,我对 Android 已经足够好了,而且我正在尝试在一个新创建的空白 react-native expo 项目中使用react-native-qrcode-scanner。我没有触及项目内部的任何内容,只是创建了一个全新的项目,我收到一条错误消息RNPermissions is null
。我认为传递有关我的 android 应用程序的详细信息很重要,有人可以帮助我如何开始吗?我正在根据 QR 代码扫描仪代码的需要使用react-native-permissions,我卸载了依赖项中的所有内容,只留下了这些:
"dependencies": {
"expo": "~36.0.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"react-native-permissions": "^2.0.2",
"react-native-web": "~0.11.7"
}
Run Code Online (Sandbox Code Playgroud)
所以只有基本的欢迎在 App.js 中响应消息,如下所示:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { check, PERMISSIONS, RESULTS } from 'react-native-permissions';
class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on …
Run Code Online (Sandbox Code Playgroud) android reactjs react-native react-native-android react-native-permissions
我正在尝试让react-native-permissions
我的 Expo 开发客户端版本运行。构建成功,但是当我启动应用程序时,我得到一个相对通用的“未检测到权限处理程序”。错误。
研究建议添加权限ios/Podfile
并确保ios/<appname>/Info.plist
条目需要存在。
该应用程序无需react-native-permissions即可运行,但我想使用该包来检查是否设置了权限并引导用户进行设置(如果没有)。
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"
Run Code Online (Sandbox Code Playgroud)
<key>NSMicrophoneUsageDescription</key>
<string>CUSTOM: Allow to access the microphone</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>CUSTOM: Allow to securely recognize user speech</string>
Run Code Online (Sandbox Code Playgroud)
...
"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/perf",
"@react-native-firebase/crashlytics",
"@react-native-google-signin/google-signin",
["react-native-fbsdk-next",
{
"appID": "xxx",
"clientToken": "xxx",
"displayName": "xxx",
"advertiserIDCollectionEnabled": false,
"autoLogAppEventsEnabled": false,
"isAutoInitEnabled": true
}
],
[
"@react-native-voice/voice",
{
"microphonePermission": "CUSTOM: Allow access the microphone",
"speechRecognitionPermission": "CUSTOM: to securely recognize user speech"
}
] …
Run Code Online (Sandbox Code Playgroud) javascript react-native expo react-native-permissions expo-eas
我在我的 React Native 应用程序中使用react-native-camera-roll/camera-roll@5.2.0。对于 Android 13,READ_EXTERNAL_STORAGE 权限已替换为 READ_MEDIA_IMAGES。我使用以下代码来检查是否已授予权限:
const permission = Platform.Version >= 33 ? PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES : PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE;
const hasPermission = await PermissionsAndroid.check(permission);
Run Code Online (Sandbox Code Playgroud)
然而,PermissionsAndroid.PERMISSIONS
不包含READ_MEDIA_IMAGES
,所以permission
也是undefined
。传递undefined
给PermissionsAndroid.check()
会使应用程序挂起。
我想知道的是:
我正在使用react-native@0.65.3。PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES 直到 0.70 才可用,所以除非我更新到 0.70,否则permission
将始终是undefined
. 我该如何解决这个问题?
permissions android-permissions reactjs react-native react-native-permissions
这里提到的解决方案讨论了如何使用 ATTrackingManager 类进行设置,但是,它没有直接暴露给 React Native。
使用react-native-tracking-transparency包在构建时给我带来了一个问题:
“未定义的符号_RCTRegisterModule”
因为只有在不包含 use_flipper 时它才有效!在你的podfile中......所以我被困住了,不想按照这里的解决方案中的建议进行补丁包(这意味着修复已经被合并,但在用这个构建时我仍然看到“未定义的符号_RCTRegisterModule”......
想知道是否有针对 React Native 的 ATTrackingManager 类的包装器?
我正在使用react-native-qr-code-scanner在我的应用程序中添加 QR 扫描仪功能。我遵循了所有的 instaruction 并且在 android 上一切正常,但是当我在 ios 上构建我的应用程序时,应用程序无法找到该RNPermissions
库,因此我按照自述文件中的建议手动链接它。链接错误现在消失了,我得到了 Invali RMPermission ios.PERMISSION.CAMERA should be one of()
。该错误在react-native-permissions README PAGE的 github 页面和解决它的步骤中有所描述。它说
检查您是否链接了至少一个权限处理程序。
我无法将那里描述的权限处理程序添加到 Podfile,因为它会React(0.11.0)
自动安装版本(但这不是必需的),因为我已经有了最新的反应。解决这个问题的方法是什么?
[!]
pod install
添加后运行时
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
Run Code Online (Sandbox Code Playgroud)
我明白了
Unable to find a specification for `RNPermissions` depended upon by `Permission-Camera`
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or …
Run Code Online (Sandbox Code Playgroud) 我在反应本机权限原理方面遇到了麻烦。尽管我已经将其放入我的代码中,但它没有显示。
const rationale = { title: 'Permission', message: 'message' }
const res = await PermissionsAndroid.request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION, rationale);
Run Code Online (Sandbox Code Playgroud)
是什么问题导致不显示呢?感谢您的帮助。