提交 933a50bd authored 作者: JarvanMo's avatar JarvanMo

update launch from app.

上级 a6f7f0d0
......@@ -21,6 +21,7 @@
- Launch mini program in WeChat.
- Subscribe Message.
- Just open WeChat app.
- Launch app From wechat link.
## Preparation
......@@ -72,6 +73,7 @@ And you have to understand the difference between debug signature and release si
- [Share](./doc/SHARE.md)
- [Payment](./doc/PAYMENT.md)
- [Auth](./doc/AUTH.md)
- [Launch app from h5](./doc/LAUNCH_APP_FROM_H5.md)
For more capabilities, you can read the public functions of `fluwx`.
......
......@@ -19,6 +19,7 @@
- 拉起小程序.
- 订阅消息.
- 打开微信.
- 从微信标签打开应用
## 准备
......@@ -70,7 +71,7 @@ registerWxApi(appId: "wxd930ea5d5a228f5f",universalLink: "https://your.univerall
- [分享](./doc/SHARE_CN.md)
- [支付](./doc/PAYMENT_CN.md)
- [登录](./doc/AUTH_CN.md)
- [从微信标签打开应用](./doc/LAUNCH_APP_FROM_H5_CN.md)
对于更多功能,可以查看源码。
## QA
......
......@@ -80,8 +80,8 @@ object FluwxRequestHandler {
fun onReq(baseReq: BaseReq, activity: Activity) {
try {
val appInfo = activity.packageManager.getApplicationInfo(activity.packageName, PackageManager.GET_META_DATA)
val defaultHandle = appInfo.metaData.getBoolean("handleWeChatRequestByFluwx", true)
val activityInfo = activity.packageManager.getActivityInfo(activity.componentName, PackageManager.GET_META_DATA)
val defaultHandle = activityInfo.metaData.getBoolean("handleWeChatRequestByFluwx", true)
if (defaultHandle) {
defaultOnReqDelegate(baseReq, activity)
} else {
......
## Launch App from H5
Fluwx supports launch app from `<wx-open-launch-app>`, and pass `extInfo` to your app.
For Android side, you need add the following action for your FlutterActivity in `AndroidManifest.xml`:
```
<action android:name="${applicationId}.FlutterActivity" />
```
If you want to pass `extInfo` to Flutter, you need to add the following code in `MainActivity.kt`:
```kotlin
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
//If you didn't configure WxAPI, add the following code
WXAPiHandler.setupWxApi("wxd930ea5d5a258f4f",this)
//Get Ext-Info from Intent.
FluwxRequestHandler.handleRequestInfoFromIntent(intent)
}
```
If you want to custom your request logic, you need add the `<meta-data>` in host activity:
```xml
<meta-data
android:name="handleWeChatRequestByFluwx"
android:value="flase" />
```
And then, set `FluwxRequestHandler.customOnReqDelegate` on your own.
\ No newline at end of file
## 从H5启动app
Fluwx 支持从`<wx-open-launch-app>`启动你的app, 并且支持传递`extInfo`给你的app.
对于Android来说,你要在`AndroidManifest.xml`中给你的宿主`Activty`加上一个标签:
```
<action android:name="${applicationId}.FlutterActivity" />
```
如果你想把`extInfo`传给Flutter, 你要在`MainActivity`加上如下代码:
```kotlin
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
//If you didn't configure WxAPI, add the following code
WXAPiHandler.setupWxApi("wxd930ea5d5a258f4f",this)
//Get Ext-Info from Intent.
FluwxRequestHandler.handleRequestInfoFromIntent(intent)
}
```
如果你想自定义你的调用逻辑, 你需要在宿主Activity中加上`<meta-data>`:
```xml
<meta-data
android:name="handleWeChatRequestByFluwx"
android:value="flase" />
```
然后, 自己实现 `FluwxRequestHandler.customOnReqDelegate`.
\ No newline at end of file
......@@ -23,14 +23,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="handleWeChatRequestByFluwx"
android:value="false" />
</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" />
<meta-data
android:name="handleWeChatRequestByFluwx"
android:value="false" />
</application>
</manifest>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论