我正在阅读React Native中的文档,并且只能从我所在的应用程序中找到导航到外部链接.
我希望能够导航到Settings应用程序(更具体地说是导航到隐私>位置服务页面),但似乎无法找到相关信息.有一种原生的iOS方式,我试图通过React Native复制它.
这可能吗?
我已尝试以下方法来检测是否存在设置URL.控制台记录Settings url works但是,它不会导航到该页面.
更新:感谢@zvona我现在正在导航到设置页面,但不知道如何进入特定的深层链接.
Linking.canOpenURL('app-settings:').then(supported => {
console.log(`Settings url works`)
Linking.openURL('app-settings:'
}).catch(error => {
console.log(`An error has occured: ${error}`)
})
Run Code Online (Sandbox Code Playgroud)
zvo*_*ona 46
您可以访问应用程序的设置:
Linking.openURL('app-settings:');
但我不知道(还)如何打开特定的深层链接.
tok*_*are 12
我通过下面的代码成功打开了设置,希望它有用:)
Linking.canOpenURL('app-settings:').then(supported => {
if (!supported) {
console.log('Can\'t handle settings url');
} else {
return Linking.openURL('app-settings:');
}
}).catch(err => console.error('An error occurred', err));
Run Code Online (Sandbox Code Playgroud)
参考:https://facebook.github.io/react-native//docs/linking.html
mat*_*hew 12
从 React Native 0.59 版开始,这应该可以使用openSettings();. 这在 React Native Linking 文档中有所描述。虽然它对我不起作用。当我快速尝试时,我看到了一条_reactNative.Linking.openSettings is not a function错误消息。
Linking.openSettings();
Run Code Online (Sandbox Code Playgroud)
小智 7
您可以深入链接引用设置的索引,如下所示:
Linking.openURL('app-settings:{index}')
Run Code Online (Sandbox Code Playgroud)
例如,Linking.openURL('app-settings:{3}')将打开蓝牙设置.
| 归档时间: |
|
| 查看次数: |
18481 次 |
| 最近记录: |