【发布时间】:2017-11-18 20:15:47
【问题描述】:
我想从我的应用中打开 ios 设置应用。设置目标是 [ settings => notification => myapp ]。打开和关闭推送通知。
有一些关于如何链接到设置的文档,但我不知道如何打开深层链接。 (通知 => myapp)。
我该怎么做?
【问题讨论】:
-
如何在我的应用中点击按钮后打开外部应用
标签: react-native react-native-ios
我想从我的应用中打开 ios 设置应用。设置目标是 [ settings => notification => myapp ]。打开和关闭推送通知。
有一些关于如何链接到设置的文档,但我不知道如何打开深层链接。 (通知 => myapp)。
我该怎么做?
【问题讨论】:
标签: react-native react-native-ios
对于 iOS 14,这是我打开位置服务设置的方式
Linking.openURL('App-Prefs:Privacy&path=LOCATION')
在 react native 0.63.4 中测试
【讨论】:
从 React Native 0.60 开始打开 App 设置使用:
import { Linking } from 'react-native';
Linking.openSettings();
打开“设置”应用并显示应用的自定义设置(如果有)。
适用于 Android 和 iOS
【讨论】:
Linking.openURL('App-Prefs:LOCATION_SERVICES')
Could not open URL 'App-Prefs:LOCATION_SERVICES': No Activity found to handle Intent { act=android.intent.action.VIEW dat=app-prefs:LOCATION_SERVICES flg=0x10000000 }
试试这个开放特定系统 URL - Linking.openURL('App-Prefs:{3}')
【讨论】:
试试这个
Linking.openURL('app-settings://notification/myapp')
【讨论】:
使用Linking.openURL。例如,下面是如何在 iOS 上查看和打开 Health 应用
import { Linking } from 'react-native'
async goToSettings() {
const healthAppUrl = 'x-apple-health://'
const canOpenHealthApp = await Linking.canOpenURL(healthAppUrl)
if (canOpenHealthApp) {
Linking.openURL(healthAppUrl)
} else {
Linking.openURL('app-settings:')
}
}
【讨论】:
要访问特定设置屏幕,请尝试以下操作:
Linking.openURL("App-Prefs:root=WIFI");
链接到 app-settings 只会打开
参考:iOS Launching Settings -> Restrictions URL Scheme(注意prefs在iOS 6中改为App-Prefs)
【讨论】:
root=
您可以像这样对引用设置的索引进行深层链接:
Linking.openURL('app-settings:')
以上方法仅适用于IOS
【讨论】:
Linking.openURL('app-settings://notification/myapp')}