gpt4 book ai didi

android - 如何为 react-native 应用程序设置 URL 方案/链接

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:57:36 25 4
gpt4 key购买 nike

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

最佳答案

要指定 URL 方案,请修改您的 AndroidManifest.xml 并在 react native 提供的过滤器下添加一个额外的 intent-filter。使用您的值更新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 - 如何为 react-native 应用程序设置 URL 方案/链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36244507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com