feat:自定义api修改回调处理逻辑,与安卓同步
parent
d9445020f6
commit
d84646a42f
|
@ -22,15 +22,28 @@
|
||||||
NSString* api = [@"extensionApi:" stringByAppendingString:self.name];
|
NSString* api = [@"extensionApi:" stringByAppendingString:self.name];
|
||||||
[channel invokeMethod:api arguments:param result:^(id _Nullable result) {
|
[channel invokeMethod:api arguments:param result:^(id _Nullable result) {
|
||||||
NSLog(@"extensionApi reslut:%@",result);
|
NSLog(@"extensionApi reslut:%@",result);
|
||||||
|
// 先判断是否flutter发生错误
|
||||||
BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented;
|
BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented;
|
||||||
BOOL hasError = [[result allKeys] containsObject:@"errMsg"];
|
if (isFlutterError) {
|
||||||
if (isFlutterError || hasError) {
|
|
||||||
NSLog(@"extensionApi reslut:fail");
|
NSLog(@"extensionApi reslut:fail");
|
||||||
callback(FATExtensionCodeFailure,nil);
|
callback(FATExtensionCodeFailure,nil);
|
||||||
} else {
|
return;
|
||||||
NSLog(@"extensionApi callback:%@",result);
|
|
||||||
callback(FATExtensionCodeSuccess,result);
|
|
||||||
}
|
}
|
||||||
|
// 再判断回调是否为失败
|
||||||
|
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(@{});
|
success(@{});
|
||||||
|
|
Loading…
Reference in New Issue