Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): resolve compatibility issue when using ResponseSenderBlock #4040

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions framework/ios/base/modules/HippyModuleMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading