首页 > 解决方案 > Flutter 上的 Http 链接在 Android 设备上不起作用

问题描述

在uni_links库的帮助下,我将浏览器中的支付屏幕与应用程序连接起来,以便在支付成功后链接回应用程序。这一切都在 iOS 上按预期工作,并使用返回 url 打开应用程序。但是在 Android 上甚至没有调用回调,它会通知我返回 url,即使应用程序已打开,这意味着 http 链接部分有效。

这是我在 Android Manifest 文件中添加的内容:

<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="www.redirect.mydomain.eu"
        android:pathPrefix="/return_url"/>
</intent-filter>

这是我正在收听的来自 uni_links 的回调,以便它使用返回 url 字符串触发,但它根本不会在 Android 上触发:

_subscription = getLinksStream().listen((String link) {
  // Handle success case
}, onError: (err) {
  // Handle exception by warning the user their action did not succeed
});

知道为什么这根本不适用于Android吗?

标签: androidflutter

解决方案


推荐阅读