提交 93461f25 authored 作者: lopo's avatar lopo

docs: update doc for section 'Launch App From H5'

上级 5ef94a38
## WeChat reference document
- [WeChat open label jumps to APP: <wx-open-launch-app>](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html#%E8%B7%B3%E8%BD%ACAPP%EF%BC%9Awx-open-launch-app)
- [App gets the extinfo data in the open tag <wx-open-launch-app>](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/APP_GET_EXTINF.html)
## Platform differences
- The event type of **Launch-App-From-H5** on Android is `WeChatShowMessageFromWXRequest`
- The event type of **Launch-App-From-H5** on IOS is `WeChatLaunchFromWXRequest`
> ### iOS specific configuration
## IOS
Please register your WXApi in your `AppDelegate`: Please register your WXApi in your `AppDelegate`:
```oc ```oc
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//向微信注册 //向微信注册
...@@ -9,4 +20,30 @@ Please register your WXApi in your `AppDelegate`: ...@@ -9,4 +20,30 @@ Please register your WXApi in your `AppDelegate`:
} }
``` ```
> If you want to get ext from website, please call ``fluwx.getExtMsg()`。`For details, please read the example. ## Example
\ No newline at end of file
```dart
void handle_launch_from_h5() {
Fluwx fluwx = Fluwx();
fluwx.addSubscriber((response) {
// 1. Handle responses separately for android and ios
if (response is WeChatShowMessageFromWXRequest) {
debugPrint("launch-app-from-h5 on android");
// do something here only for android after launch from wechat
} else if (response is WeChatLaunchFromWXRequest) {
debugPrint("launch-app-from-h5 on ios");
// do something here only for android after launch from wechat
}
// 2. Or handling responses together for android and ios
if (response is WeChatLaunchFromWXRequest ||
response is WeChatShowMessageFromWXRequest) {
debugPrint("launch-app-from-h5");
// do something here for both android and ios after launch from wechat
}
});
}
```
> If you want to get ext from website, please call `fluwx.getExtMsg()`。For details, please read the example project.
## 微信参考文档
- [微信开放标签 &lt;wx-open-launch-app&gt; 跳转App](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html#%E8%B7%B3%E8%BD%ACAPP%EF%BC%9Awx-open-launch-app)
- [App获取开放标签 &lt;wx-open-launch-app&gt; 中的 extinfo 数据](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/APP_GET_EXTINF.html)
## 平台差异
- 安卓端 **微信唤起App** 的事件类型为 `WeChatShowMessageFromWXRequest`
- IOS端 **微信唤起App** 的事件类型为 `WeChatLaunchFromWXRequest`
> ### iOS 特定配置
## IOS
请在你的`AppDelegate`中主动注册`WXApi` 请在你的`AppDelegate`中主动注册`WXApi`
```oc ```oc
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//向微信注册 //向微信注册
...@@ -9,5 +20,30 @@ ...@@ -9,5 +20,30 @@
} }
``` ```
> 如你想主动获取从网页传进来的值 ,请主动调用`fluwx.getExtMsg()`。更多信息请参考example. ## 示例
```dart
void handle_launch_from_h5() {
Fluwx fluwx = Fluwx();
fluwx.addSubscriber((response) {
// 1. 为安卓和ios分开处理响应
if (response is WeChatShowMessageFromWXRequest) {
debugPrint("launch-app-from-h5 on android");
// 从微信启动后,在这里只为 android 做一些事情
} else if (response is WeChatLaunchFromWXRequest) {
debugPrint("launch-app-from-h5 on ios");
// 从微信启动后,在这里只为 ios 做一些事情
}
// 2. 或者为安卓和ios一起处理响应
if (response is WeChatLaunchFromWXRequest ||
response is WeChatShowMessageFromWXRequest) {
debugPrint("launch-app-from-h5");
// 从微信启动后,在这里为 android 和 ios 做一些事情
}
});
}
```
> 如你想主动获取从网页传进来的值 ,请主动调用`fluwx.getExtMsg()`。更多信息请参考example项目.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论