Esh*_*zir 6 permissions settings react-native react-native-navigation
REACTNATIVE :当前使用Linking.openSettings()打开我的应用程序设置页面。
现在,我想直接打开应用程序权限屏幕,它位于应用程序设置中,以使用 REACT NATIVE 在 Android 和 iOS 中启用位置、存储等权限。
有什么可能吗?提前致谢!
小智 6
不久之后就有可能,
对于IOS操作系统,请尝试以下,
import { Linking } from 'react-native'
Linking.openURL('app-settings:')
Run Code Online (Sandbox Code Playgroud)
但是Android不支持Linking,我们应该添加两个依赖项,
npm install --save 反应本机设备信息
npm 安装react-native-intent-launcher
因此,
import DeviceInfo from 'react-native-device-info';
import IntentLauncher, { IntentConstant } from 'react-native-intent-launcher'
const package= DeviceInfo.getBundleId();
const openAppSettings = () => {
if (Platform.OS === 'ios') {
Linking.openURL('app-settings:')
} else {
IntentLauncher.startActivity({
action: 'android.settings.APPLICATION_DETAILS_SETTINGS',
data: 'package:' + package
})
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
519 次 |
| 最近记录: |