首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用http localhost的深度链接

不使用http localhost的深度链接
EN

Stack Overflow用户
提问于 2022-10-24 08:40:05
回答 1查看 122关注 0票数 0

我正在尝试建立一个反应本地应用程序,我需要使用深度链接,以打开我的应用程序从一个链接。

问题是应用程序方案的深度链接工作,而不是与http和https方案。我还想提到,我使用localhost作为主机,所以这可能是错误的地方。

这是我的AndroidManifest文件:

代码语言:javascript
复制
<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" />

下面是我的配置:

代码语言:javascript
复制
  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网络服务器没有打开,但没关系的是,我只需要深层链接就可以启动并打开应用程序。

我做错什么了?

EN

回答 1

Stack Overflow用户

发布于 2022-10-25 05:56:16

您可以使用ADB https://developer.android.com/training/app-links/deep-linking#testing-filters实用程序检查深度链接:

代码语言:javascript
复制
adb shell am start -W -a android.intent.action.VIEW -d "your deep link URL"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74178528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档