feat:自定义api修改回调处理逻辑,与安卓同步

master
jizelin 2021-08-20 17:01:15 +08:00
parent d9445020f6
commit d84646a42f
1 changed files with 18 additions and 5 deletions

View File

@ -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 {
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(@{});