Flutter安卓端Branch Deep Link初始化无响应,返回后恢复正常
安卓端Flutter+Branch Deep Link接收异常问题
问题现象
- 从WhatsApp等应用点击Deep Link打开App时,App能启动但无法接收链接;从最近应用切回WhatsApp再次点击仍无效,按下设备返回键回到WhatsApp后,后续链接可正常工作。
- 手动启动App后,前往WhatsApp点击链接,App启动但无法接收链接;从最近应用切回WhatsApp再次点击仍无效,按下返回键回到WhatsApp后,后续链接恢复正常。
Android Manifest Activity配置
<activity android:name=".MainActivity" android:exported="true" android:enableOnBackInvokedCallback="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"> <!-- Branch URI Scheme --> <intent-filter android:autoVerify="true"> <data android:scheme="..."/> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> </intent-filter> <!-- Branch App Links - Live App --> <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="https" android:host="....app.link"/> <data android:scheme="https" android:host="...-alternate.app.link"/> </intent-filter> </activity>
Flutter Doctor输出
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.4 23E214 darwin-arm64, locale it-IT) • Flutter version 3.19.3 on channel stable at /Users/dev/FlutterDev/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ba39319843 (4 weeks ago), 2024-03-07 15:22:21 -0600 • Engine revision 2e4ba9c6fb • Dart version 3.3.1 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at /Users/dev/Library/Android/sdk • Platform android-34, build-tools 32.1.0-rc1 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874) • All Android licenses accepted. • No issues found!
已尝试的解决方案
- 修改launchMode为singleTop,导致多次打开链接并在WhatsApp中创建新实例
- 添加
android:allowTaskReparenting="true"、android:alwaysRetainTaskState="true"属性 - 切换launchMode为singleInstance、standard模式
以上方案均未解决问题。
内容的提问来源于stack exchange,提问作者Andrea Bigini
相关产品推荐
相关产品推荐

