【问题标题】:React Native Open settings through Linking.openURL in IOS通过 IOS 中的 Linking.openURL React Native Open 设置
【发布时间】:2017-11-18 20:15:47
【问题描述】:

我想从我的应用中打开 ios 设置应用。设置目标是 [ settings => notification => myapp ]。打开和关闭推送通知。

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

我该怎么做?

【问题讨论】:

  • 如何在我的应用中点击按钮后打开外部应用

标签: react-native react-native-ios


【解决方案1】:

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

Linking.openURL('App-Prefs:Privacy&path=LOCATION')

在 react native 0.63.4 中测试

【讨论】:

    【解决方案2】:

    从 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 }
    • 抱歉,这是针对 ios 的。对于 android,我使用这个库 'react-native-settings'
    【解决方案3】:

    试试这个开放特定系统 URL - Linking.openURL('App-Prefs:{3}')

    【讨论】:

      【解决方案4】:

      试试这个

      Linking.openURL('app-settings://notification/myapp')
      

      【讨论】:

        【解决方案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:')
          }
        }
        

        【讨论】:

        • 如何在我的应用中点击按钮后打开外部应用
        【解决方案6】:

        要访问特定设置屏幕,请尝试以下操作: Linking.openURL("App-Prefs:root=WIFI"); 链接到 app-settings 只会打开 参考:iOS Launching Settings -> Restrictions URL Scheme(注意prefs在iOS 6中改为App-Prefs

        【讨论】:

        • 其他人试过这个吗?不幸的是,它在 iOS 11(模拟器和真实设备)上对我不起作用
        • 嘿,谢谢在我的情况下,'App-Prefs:root' 对我有用
        • 从 iOS 14 开始,对我有用的是 Linking.openURL("App-prefs:General") - 只需从拥有它的示例中删除 root=
        【解决方案7】:

        您可以像这样对引用设置的索引进行深层链接:

        Linking.openURL('app-settings:')
        

        以上方法仅适用于IOS

        【讨论】:

        • 如何访问更深?到 'notification => myapp' 。 .这是我的问题...
        • 这个链接对你有帮助medium.com/react-native-training/…
        • 谢谢。我可以用Linking.openURL('app-settings://notification/myapp')}
        • 有什么不需要外部库的android解决方案吗?
        • @Arunkumar 你知道 Android 的等价物吗?
        猜你喜欢
        • 2021-08-31
        • 2017-09-07
        • 2017-07-06
        • 1970-01-01
        • 2021-09-22
        • 2022-09-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多