diff --git a/framework/ios/base/modules/HippyModuleMethod.mm b/framework/ios/base/modules/HippyModuleMethod.mm index 507ccec7c21..3490b40217a 100644 --- a/framework/ios/base/modules/HippyModuleMethod.mm +++ b/framework/ios/base/modules/HippyModuleMethod.mm @@ -307,7 +307,11 @@ - (void)processMethodSignature { // so it is not a Number anymore. // See NativeRenderManager::CallFunction() for more. // TODO: add more type check for safe - blockArg = json; + blockArg = ^(NSArray *args){ + // Since the block passed from UIManager's dispatchFunction method is of type HippyPromiseResolve, + // a small conversion is required here to avoid compatibility issues. + ((HippyPromiseResolveBlock)json)(args.count > 0 ? args.firstObject : NSNull.null); + }; } else { __weak HippyBridge *weakBridge = bridge; blockArg = ^(NSArray *args){ @@ -325,7 +329,11 @@ - (void)processMethodSignature { // so it is not a Number anymore. // See NativeRenderManager::CallFunction() for more. // TODO: add more type check for safe - blockArg = json; + blockArg = ^(NSError *error) { + // Since the block passed from UIManager's dispatchFunction method is of type HippyPromiseResolve, + // a small conversion is required here to avoid compatibility issues. + ((HippyPromiseResolveBlock)json)(HippyJSErrorFromNSError(error)); + }; } else { __weak HippyBridge *weakBridge = bridge; blockArg = ^(NSError *error) { @@ -368,7 +376,12 @@ - (void)processMethodSignature { // so it is not a Number anymore. // See NativeRenderManager::CallFunction() for more. // TODO: add more type check for safe - blockArg = json; + blockArg = ^(NSString *code, NSString *message, NSError *error) { + // Since the block passed from UIManager's dispatchFunction method is of type HippyPromiseResolve, + // a small conversion is required here to avoid compatibility issues. + NSDictionary *errorJSON = HippyJSErrorFromCodeMessageAndNSError(code, message, error); + ((HippyPromiseResolveBlock)json)(errorJSON); + }; } else { __weak HippyBridge *weakBridge = bridge; blockArg = ^(NSString *code, NSString *message, NSError *error) {