react-native-wechat-lib
react-native-wechat-lib copied to clipboard
Android 小程序打开APP的回调方法有误,RN侧只能监听WeChat_Resp事件
@Override
public void onReq(BaseReq baseReq) {
WritableMap map = Arguments.createMap();
map.putString("openId", baseReq.openId);
map.putString("transaction", baseReq.transaction);
if (baseReq.getType() == ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX) {
ShowMessageFromWX.Req req = (ShowMessageFromWX.Req) baseReq;
// 对应JsApi navigateBackApplication中的extraData字段数据
map.putString("type", "SendMessageToWX.Resp");
map.putString("lang", req.lang);
map.putString("country", req.message.messageExt);
}
this.getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("WeChat_Resp", map);
有误的地方:
this.getReactApplicationContext() .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("WeChat_Resp", map);
中WeChat_Resp应该写成WeChat_Req
改了也监听不了
这个只是把结果告诉前端,跟前端监听的名字一样就可以了吧。