提交 00996d60 authored 作者: JarvanMo's avatar JarvanMo

fix bugs due to NPE

上级 279ed1ea
...@@ -48,16 +48,20 @@ object FluwxResponseHandler { ...@@ -48,16 +48,20 @@ object FluwxResponseHandler {
} }
private fun handleLaunchMiniProgramResponse(response: WXLaunchMiniProgram.Resp) { private fun handleLaunchMiniProgramResponse(response: WXLaunchMiniProgram.Resp) {
val result = mapOf( val result = mutableMapOf(
errStr to response.errStr, errStr to response.errStr,
WechatPluginKeys.TRANSACTION to response.transaction, WechatPluginKeys.TRANSACTION to response.transaction,
type to response.type, type to response.type,
errCode to response.errCode, errCode to response.errCode,
openId to response.openId, openId to response.openId,
"extMsg" to response.extMsg,
WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID
) )
response.extMsg?.let {
// "extMsg" to response.extMsg,
result["extMsg"] = response.extMsg
}
channel?.invokeMethod(WeChatPluginMethods.WE_CHAT_LAUNCHMINIPROGRAM_RESPONSE, result) channel?.invokeMethod(WeChatPluginMethods.WE_CHAT_LAUNCHMINIPROGRAM_RESPONSE, result)
} }
......
...@@ -16,7 +16,7 @@ class _LaunchMiniProgramPageState extends State<LaunchMiniProgramPage> { ...@@ -16,7 +16,7 @@ class _LaunchMiniProgramPageState extends State<LaunchMiniProgramPage> {
super.initState(); super.initState();
fluwx.responseFromLaunchMiniProgram.listen((data) { fluwx.responseFromLaunchMiniProgram.listen((data) {
setState(() { setState(() {
_result = "${data.extMsg}"; _result = "${data.errStr}";
}); });
}); });
......
...@@ -117,17 +117,28 @@ FlutterMethodChannel *fluwxMethodChannel = nil; ...@@ -117,17 +117,28 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
} }
WXLaunchMiniProgramResp *miniProgramResp = (WXLaunchMiniProgramResp *) resp; WXLaunchMiniProgramResp *miniProgramResp = (WXLaunchMiniProgramResp *) resp;
NSDictionary *result = @{ NSDictionary *commonResult = @{
description: miniProgramResp.description == nil ?@"":miniProgramResp.description, description: miniProgramResp.description == nil ?@"":miniProgramResp.description,
errStr: miniProgramResp.errStr == nil ?@"":miniProgramResp.errStr, errStr: miniProgramResp.errStr == nil ?@"":miniProgramResp.errStr,
errCode: @(miniProgramResp.errCode), errCode: @(miniProgramResp.errCode),
type: miniProgramResp.type == nil ?@1:@(miniProgramResp.type), type: miniProgramResp.type == nil ?@1:@(miniProgramResp.type),
fluwxKeyPlatform: fluwxKeyIOS, fluwxKeyPlatform: fluwxKeyIOS,
@"extMsg":miniProgramResp.extMsg
}; };
NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:commonResult];
if(miniProgramResp.extMsg != nil){
result[@"extMsg"] = miniProgramResp.extMsg;
}
// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg
[fluwxMethodChannel invokeMethod:@"onLaunchMiniProgramResponse" arguments:result]; [fluwxMethodChannel invokeMethod:@"onLaunchMiniProgramResponse" arguments:result];
} else if ([resp isKindOfClass:[WXInvoiceAuthInsertResp class]]) { } else if ([resp isKindOfClass:[WXInvoiceAuthInsertResp class]]) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论