【问题标题】:How to set a URL scheme/link for a react-native app如何为 react-native 应用程序设置 URL 方案/链接
【发布时间】:2016-07-14 15:49:54
【问题描述】:

我想使用 oauth 为 spotify web api 授予对 react-native 应用程序的访问权限。我知道我需要使用 linking 来处理对我的应用程序的传出/传入访问,但是我可以在哪里指定我的 react-native 应用程序的 URI 方案,以便操作系统知道使用令牌返回我的应用程序?

【问题讨论】:

    标签: android ios oauth react-native


    【解决方案1】:

    要指定 URL 方案,请修改您的 AndroidManifest.xml 并在 react native 提供的意图过滤器下添加一个额外的意图过滤器。用您的价值观更新 yourschemeyourhost

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="yourscheme"
                android:host="yourhost" />
        </intent-filter>
      </activity>
    

    【讨论】:

    • 我需要添加 android:host="" 吗?如果是,那么我应该添加什么?谢谢
    • 谢谢,我找了一天。
    【解决方案2】:

    每个平台的链接都不同。对于跨平台方法,我建议查看:http://applinks.org

    有关如何在 iOS 和 Android 上进行设置的说明,请参阅此链接:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-08
      • 1970-01-01
      • 2021-10-07
      • 2016-06-07
      • 2014-05-25
      相关资源
      最近更新 更多