微信开放标签 wx-open-launch-app 拉起 Flutter APP 白屏。

wx-open-launch-app 拉起 Flutter APP 白屏。

1、问题

这段时间我遇到了一个比较奇怪的问题,记录一下。

大家应该都知道在微信浏览器里面是无法直接拉起 APP 的,需要对接微信的开放标签 (wx-open-launch-app) 拉起 APP 。

但是在 Flutter 项目中使用微信开放标签拉起 APP 会跳转进一个 native 白屏界面,只有你返回的时候才会返回到 flutter 的 页面,这就非常的奇奇怪怪。

去各种搜索问啊,发现好像都没有什么解决办法。

一开始怀疑是项目代码有问题,但是我新建一个空白的项目去拉起还是白屏,这就比较难搞了。

2、解决它

但是,功夫只负有心人,还是让我找到解决办法了。

监听 APP 在浏览器中拉起使用的是 uni_links

对接 微信SDK 使用的是 fluwx

就是这个 fluwx 让我找到了最终的答案。

fluwx 它的 GitHub 仓库里让我发现了这个 issues

github仓库issues截图
这个 issues 的下面有个大佬的回答解决了这个问题。他让我们去参考一下 example 配置一下 meta-data 和 intent-filter。

在这里插入图片描述
我把这个example 的配置全部拿到新建的空白项目中后,就不会在跳到 native 的白屏界面。

后面就可以继续使用 浏览器拉起的逻辑了。

🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉

附录

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jarvan.fluwx_example">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <queries>
        <intent>
            <action android:name="${applicationId}.FlutterActivity" />
        </intent>
    </queries>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:label="fluwx_example">

        <meta-data
            android:name="weChatAppId"
            android:value="12345678" />

        <meta-data
            android:name="handleWeChatRequestByFluwx"
            android:value="true" />

        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:exported="true"
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="${applicationId}.FlutterActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:host="${applicationId}"
                    android:path="/"
                    android:scheme="wechatextmsg" />
            </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>
</manifest>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值