|
18 | 18 | #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRRecaptchaBridge.h" |
19 | 19 | #import "RecaptchaInterop/RecaptchaInterop.h" |
20 | 20 |
|
21 | | -void __objc_getClientWithSiteKey( |
22 | | - NSString *siteKey, |
23 | | - Class recaptchaClass, |
24 | | - void (^completionHandler)(id<RCARecaptchaClientProtocol> _Nullable result, |
25 | | - NSError *_Nullable error)) { |
26 | | - SEL selector = NSSelectorFromString(@"getClientWithSiteKey:completion:"); |
27 | | - if (recaptchaClass && [recaptchaClass respondsToSelector:selector]) { |
28 | | - void (*funcWithoutTimeout)(id, SEL, NSString *, |
29 | | - void (^)(id<RCARecaptchaClientProtocol> _Nullable recaptchaClient, |
30 | | - NSError *_Nullable error)) = |
31 | | - (void *)[recaptchaClass methodForSelector:selector]; |
32 | | - funcWithoutTimeout(recaptchaClass, selector, siteKey, |
33 | | - ^(id<RCARecaptchaClientProtocol> _Nonnull client, NSError *_Nullable error) { |
34 | | - if (error) { |
35 | | - completionHandler(nil, error); |
36 | | - } else { |
37 | | - completionHandler(client, nil); |
38 | | - } |
39 | | - }); |
| 21 | +Class<RCARecaptchaProtocol> _Nonnull __fir_castToRecaptchaProtocolFromClass(Class _Nonnull klass) { |
| 22 | + if ([klass conformsToProtocol:@protocol(RCARecaptchaProtocol)]) { |
| 23 | + NSLog(@"RCARecaptchaProtocol - true"); |
40 | 24 | } else { |
41 | | - completionHandler(nil, nil); // TODO(ncooke3): Add error just in case. |
| 25 | + NSLog(@"RCARecaptchaProtocol - false"); |
42 | 26 | } |
| 27 | + return (Class<RCARecaptchaProtocol>)klass; |
43 | 28 | } |
44 | 29 |
|
45 | | -id<RCAActionProtocol> _Nullable __fir_initActionFromClass(Class _Nonnull klass, |
46 | | - NSString *_Nonnull actionString) { |
47 | | - SEL customActionSelector = NSSelectorFromString(@"initWithCustomAction:"); |
48 | | - if (klass && [klass instancesRespondToSelector:customActionSelector]) { |
49 | | - id (*funcWithCustomAction)(id, SEL, NSString *) = |
50 | | - (id(*)(id, SEL, NSString *))[klass instanceMethodForSelector:customActionSelector]; |
51 | | - |
52 | | - id<RCAActionProtocol> customAction = |
53 | | - funcWithCustomAction([klass alloc], customActionSelector, actionString); |
54 | | - return customAction; |
| 30 | +Class<RCAActionProtocol> _Nonnull __fir_castToRecaptchaActionProtocolFromClass( |
| 31 | + Class _Nonnull klass) { |
| 32 | + if ([klass conformsToProtocol:@protocol(RCAActionProtocol)]) { |
| 33 | + NSLog(@"RCAActionProtocol - true"); |
55 | 34 | } else { |
56 | | - return nil; |
| 35 | + NSLog(@"RCAActionProtocol - false"); |
57 | 36 | } |
| 37 | + return (Class<RCAActionProtocol>)klass; |
58 | 38 | } |
59 | 39 |
|
60 | 40 | #endif |
0 commit comments