通过IOS中的Linking.openURL反应Native Open设置

Jun*_*tae 7 react-native react-native-ios

我想从我的应用程序打开ios设置应用程序.设置目的地是[settings => notification => myapp].打开和关闭推送通知.

有一些关于如何链接到设置的文档,但我不知道如何打开深层链接.(notification => myapp).

我怎样才能做到这一点?

Aru*_*mar 22

您可以深入链接引用设置的索引,如下所示:

Linking.openURL('app-settings:')
Run Code Online (Sandbox Code Playgroud)

以上方法仅适用于IOS

  • 谢谢.我可以用`Linking.openURL('app-settings:// notification/myapp')}`来做到这一点 (6认同)
  • 是否有不需要外部lib的android解决方案? (2认同)
  • @Arunkumar您知道Android的等效功能吗? (2认同)

B. *_*mad 16

由于 React Native 0.60 打开 App 设置使用:


import { Linking } from 'react-native';

Linking.openSettings();

Run Code Online (Sandbox Code Playgroud)

打开设置应用程序并显示应用程序的自定义设置(如果有)。

适用于 Android 和 iOS

  • 试试这个 `Linking.openURL('App-Prefs:LOCATION_SERVICES')` (2认同)

Abi*_*iry 6

对于 iOS 14,这就是我打开位置服务设置的方式

Linking.openURL('App-Prefs:Privacy&path=LOCATION')
Run Code Online (Sandbox Code Playgroud)

在本机反应 0.63.4 中测试


onm*_*133 5

使用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:')
  }
}
Run Code Online (Sandbox Code Playgroud)