[AC-4394] Hyperloop iOS - Converted blocks are always returning nil
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2016-08-26T14:59:27.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | Hyperloop, Titanium SDK & CLI |
Labels | blocks, callback, hyperloop |
Reporter | Rodolfo Perottoni |
Assignee | Shak Hossain |
Created | 2016-08-26T01:40:03.000+0000 |
Updated | 2016-08-26T14:59:27.000+0000 |
Description
Trying to use the Firebase SDK here.
One of the methods that i'm invoking accepts a callback block. That block is supposed to receive a few parameters.
If i build my project and try to invoke that method, my callback function never receives any parameters back from "native side".
*Why is it happening:*
Seems like HyperLoop is invoking the callback blocks with *nil*, as you can see below. This applies for all the block conversion methods in the generated *.m* files (inside */build/hyperloop/.../.../*)
+ (id) Block_void_____FIRUser____NSError___:(KrollCallback *) callback {
return [^(FIRUser * arg0, NSError * arg1) {
void(^Callback)(void) = ^{
NSArray *args = nil;
id _arg0 = (arg0 == nil || [(id)arg0 isEqual:[NSNull null]]) ? (id)[NSNull null] : (id)[HyperloopPointer pointer:(__bridge void *)arg0 encoding:@encode(id)];
id _arg1 = (arg1 == nil || [(id)arg1 isEqual:[NSNull null]]) ? (id)[NSNull null] : (id)[HyperloopPointer pointer:(__bridge void *)arg1 encoding:@encode(id)];
args = @[_arg0, _arg1];
[HyperloopUtils invokeCallback:callback args:nil thisObject:callback];
};
if ([NSThread isMainThread]) {
Callback();
} else {
dispatch_async(dispatch_get_main_queue(), Callback);
}
} copy];
}
This line:
[HyperloopUtils invokeCallback:callback args:nil thisObject:callback];
is supposed to be like this:
[HyperloopUtils invokeCallback:callback args:args thisObject:callback];
Like i said... this applies for every single block conversion methods in generated *.m* files. There is proof of this in the UIKit.m generated when you build the HyperLoop Examples project.
Just as a proof, on our Firebase module the usual return of the callback function (createUserWithEmail) is: [INFO] User = null [INFO] error = null While the return after changing the '.m' file generated is: [INFO] User = null [INFO] error = Error Domain=FIRAuthErrorDomain Code=17007 "The email address is already in use by another account." UserInfo={NSLocalizedDescription=The email address is already in use by another account., error_name=ERROR_EMAIL_ALREADY_IN_USE}