From b98ecb50b51526e52739fcd0a8782c16d98d96ac Mon Sep 17 00:00:00 2001 From: little-snow-fox Date: Wed, 8 Apr 2020 09:29:59 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E4=BE=8B=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 +++++++++++++++++++++ package.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 50159f5..2a177c2 100644 --- a/README.md +++ b/README.md @@ -375,6 +375,27 @@ Sends request for proceeding payment, then returns an object: | templateId | String | 订阅消息模板 ID,在微信开放平台提交应用审核通过后获得 | | reserved | String | 用于保持请求和回调的状态,授权请后原样带回给第三方。该参数可用于防止 csrf 攻击(跨站请求伪造攻击),建议第三方带上该参数,可设置为简单的随机数加 session 进行校验,开发者可以填写 a-zA-Z0-9 的参数值,最多 128 字节,要求做 urlencode | +#### 订阅回调事件 +``` + WeChat.registerApp(Global.APP_ID, Global.UNIVERSAL_LINK); + DeviceEventEmitter.addListener('WeChat_Req', req => { + console.log('req:', req) + if (req.type === 'LaunchFromWX.Req') { // 从小程序回到APP的事件 + miniProgramCallback(req.extMsg) + } + }); + DeviceEventEmitter.addListener('WeChat_Resp', resp => { + console.log('res:', resp) + if (resp.type === 'WXLaunchMiniProgramReq.Resp') { // 从小程序回到APP的事件 + miniProgramCallback(resp.extMsg) + } else if (resp.type === 'SendMessageToWX.Resp') { // 发送微信消息后的事件 + sendMessageCallback(resp.country) + } else if (resp.type === 'PayReq.Resp') { // 支付回调 + payCallback(resp) + } + }); +``` + ## License MIT diff --git a/package.json b/package.json index b7e20a5..816ceb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-wechat-lib", - "version": "1.1.15", + "version": "1.1.16", "description": "react-native library for wechat app. 支持分享和拉起小程序。", "main": "index.js", "scripts": {