From d84646a42fcd5dc3f285a7de3570e52eea77f386 Mon Sep 17 00:00:00 2001 From: jizelin Date: Fri, 20 Aug 2021 17:01:15 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=AE=9A=E4=B9=89api?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=9E=E8=B0=83=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=B8=8E=E5=AE=89=E5=8D=93=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOP_registerExtensionApi.m | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ios/Classes/Api/MOP_registerExtensionApi.m b/ios/Classes/Api/MOP_registerExtensionApi.m index d86d4d4..c1dedaf 100644 --- a/ios/Classes/Api/MOP_registerExtensionApi.m +++ b/ios/Classes/Api/MOP_registerExtensionApi.m @@ -22,15 +22,28 @@ NSString* api = [@"extensionApi:" stringByAppendingString:self.name]; [channel invokeMethod:api arguments:param result:^(id _Nullable result) { NSLog(@"extensionApi reslut:%@",result); + // 先判断是否flutter发生错误 BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented; - BOOL hasError = [[result allKeys] containsObject:@"errMsg"]; - if (isFlutterError || hasError) { + if (isFlutterError) { NSLog(@"extensionApi reslut:fail"); callback(FATExtensionCodeFailure,nil); - } else { - NSLog(@"extensionApi callback:%@",result); - callback(FATExtensionCodeSuccess,result); + return; } + // 再判断回调是否为失败 + BOOL hasError = [[result allKeys] containsObject:@"errMsg"]; + if (hasError) { + NSString *errMsg = result[@"errMsg"]; + NSString *errPrefix = [NSString stringWithFormat:@"%@:fail", self.name]; + BOOL isFail = [errMsg hasPrefix:errPrefix]; + if (isFail) { + NSLog(@"extensionApi reslut:fail"); + callback(FATExtensionCodeFailure,nil); + return; + } + } + // 其他的按成功处理 + NSLog(@"extensionApi callback:%@",result); + callback(FATExtensionCodeSuccess,result); }]; }]; success(@{});