React Native Deep Linking - 所有 URL 的 Android 应用程序打开对于配置的域

问题描述

我们将原生 Android 应用程序转换为 React 原生应用程序,并为新应用程序使用了博览会管理的工作流程。对于深层链接,我们使用了 expo 中的 linking documentation,一切正常。但是最近我们注意到对于一些用户(特别是三星设备),Android App 正在为所有 URL(对于配置的域)开放。

意图过滤器设置:

{
  "expo": {
    "android": {
      "intentFilters": [
        {
          "action": "VIEW","data": [
            {
              "scheme": "https","host": "*.domain.com","pathPrefix": "/jobs"
            },{
              "scheme": "https","pathPrefix": "/can/recommended-jobs"
            },"pathPrefix": "/can/cv-views"
            },"pathPrefix": "/can/conversations"
            },"pathPrefix": "/can/profile/basic-info"
            },"pathPattern": "/.*/jobs/.*-.*"
            },"pathPrefix": "/mobile/can/profile"
            },"pathPrefix": "/mobile/can/cv-views"
            },"pathPrefix": "/mobile/"
            },"pathPrefix": "/mobile/jobs/country"
            },"pathPattern": "/mobile/jobs-in-.*/.*/.*"
            }
          ],"category": ["broWSABLE","DEFAULT"]
        }
      ]
    }
  }
}

即使在 Expo 裸工作流中退出 Expo 后,上述问题仍然存在。

弹出后的 Android Menifest 看起来像这样。

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.android.dev">
  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:requestLegacyExternalStorage="true">
    <Meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="41.0.0"/>
    <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:screenorientation="portrait">
      <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="com.company"/>
        <data android:scheme="com.company.android.dev"/>
      </intent-filter>
      <intent-filter>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/jobs"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/can/recommended-jobs"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/can/cv-views"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/can/conversations"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/can/profile/basic-info"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPattern="/.*/jobs/.*-.*"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/mobile/can/profile"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/mobile/can/cv-views"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/mobile/"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPrefix="/mobile/jobs/country"/>
        <data android:scheme="https" android:host="*.domain.com" android:pathPattern="/mobile/jobs-in-.*/.*/.*"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.broWSABLE"/>
        <category android:name="android.intent.category.DEFAULT"/>
      </intent-filter>
    </activity>
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.broWSABLE"/>
      </intent-filter>
    </activity>
  </application>
</manifest>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)