我正在尝试建立一个反应本地应用程序,我需要使用深度链接,以打开我的应用程序从一个链接。
问题是应用程序方案的深度链接工作,而不是与http和https方案。我还想提到,我使用localhost作为主机,所以这可能是错误的地方。
这是我的AndroidManifest文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.area">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="com.area.MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter android:autoVerify="true">
<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="area" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="localhost:8081" />
<data android:scheme="https" android:host="localhost:8081" />
</intent-filter>
</activity>
</application>
</manifest>如你所见,
我设置了<data android:scheme="http" android:host="localhost:8081" />和
<data android:scheme="area" />
下面是我的配置:
const linking = {
prefixes: ["area://", 'http://localhost:8081'],
config: {
screens: {
Login: 'Login',
Register: 'Register',
Auth: 'Auth',
ForgotPassword: 'ForgotPassword',
ResetPassword: 'ResetPassword',
Homepage: '',
Create: 'Create',
Activity: 'Activity',
User: 'Areas'
}
}
};
export default linking;现在一切都正常了,所以我试着用以下命令测试我的深度链接:
npx uri-scheme open area:// --android,它工作并打开应用程序。

和
npx uri-scheme open http://localhost:8081 --android,它只打开导航器

本地主机:8081网络服务器没有打开,但没关系的是,我只需要深层链接就可以启动并打开应用程序。
我做错什么了?
发布于 2022-10-25 05:56:16
您可以使用ADB https://developer.android.com/training/app-links/deep-linking#testing-filters实用程序检查深度链接:
adb shell am start -W -a android.intent.action.VIEW -d "your deep link URL"https://stackoverflow.com/questions/74178528
复制相似问题