You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用Deep Link无法在全场景唤起问题求助

问题现象

在Flutter应用中集成Deep Link后,通过Discord发送链接并点击「访问网站」可正常唤起应用,但通过Instagram发送链接或扫描二维码时,只会在三星浏览器中打开链接,无法唤起应用。测试设备为三星S10(Android 12),除Discord外的其他场景均出现此问题。

相关代码

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:label="example_project"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <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" />
                <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
                <data
                    android:scheme="https"
                    android:host="example-app.at"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <!-- Required to query activities that can process text, see:
         https://developer.android.com/training/package-visibility?hl=en and
         https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

         In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
        <intent>
            <action android:name="android.intent.action.INSERT" />
            <data android:mimeType="vnd.android.cursor.item/event" />
        </intent>
    </queries>


</manifest>

应用内分享代码

onPressed: () async {
    final result = await Share.share(
        'Tritt meiner Party auf Example bei: https://example-app.at/joinParty/${id}',
        subject: 'Tritt meiner Party bei');

    if (result.status == ShareResultStatus.success) {
        Navigator.pop(context);
    }
},

解决方案建议

1. 确认App Links验证状态

你的intent-filter已添加android:autoVerify="true",但需确保域名example-app.at的.well-known目录下正确配置了assetlinks.json文件。Android 12+对App Links验证要求严格,若验证失败,系统会直接用浏览器打开链接而非唤起应用。

2. 添加自定义Scheme的Intent Filter

除HTTPS格式的App Links外,新增自定义Scheme的Intent Filter,覆盖不支持App Links的场景(如二维码扫描、部分社交应用的链接处理):

<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="exampleapp" android:host="joinParty" />
</intent-filter>

分享时可同时提供HTTPS和自定义Scheme链接,或通过后端跳转:用户打开HTTPS链接时,若检测到应用已安装则跳转至自定义Scheme唤起应用,否则引导下载。

3. 适配三星浏览器的特殊逻辑

三星浏览器处理Deep Link可能存在特殊行为,可尝试:

  • 在系统设置→应用→默认应用中,将你的应用设为对应链接的默认处理程序;
  • 检查三星浏览器的「链接打开方式」设置,是否强制用浏览器打开所有链接。

4. 调试Intent跳转

用adb命令调试Intent,确认系统是否能正确匹配应用:

adb shell am start -W -a android.intent.action.VIEW -d "https://example-app.at/joinParty/test"

若命令能唤起应用,说明Intent Filter配置正确,问题出在第三方应用(Instagram、二维码扫描器)的链接处理逻辑;若无法唤起,需检查App Links验证或Intent Filter配置。


内容的提问来源于stack exchange,提问作者ngrave

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 09:58:11