|
24 | 24 | static void retrieveToken(NSString *actionString, |
25 | 25 | NSString *fakeToken, |
26 | 26 | FIRAuthRecaptchaTokenCallback callback) { |
27 | | - Class RecaptchaActionClass = NSClassFromString(@"RecaptchaAction"); |
| 27 | + Class RecaptchaActionClass = NSClassFromString(@"RecaptchaEnterprise.RCAAction"); |
28 | 28 | SEL customActionSelector = NSSelectorFromString(@"initWithCustomAction:"); |
| 29 | + if (!RecaptchaActionClass) { |
| 30 | + // Fall back to attempting to connect with pre-18.7.0 RecaptchaEnterprise. |
| 31 | + RecaptchaActionClass = NSClassFromString(@"RecaptchaAction"); |
| 32 | + } |
| 33 | + |
29 | 34 | if (RecaptchaActionClass && |
30 | 35 | [RecaptchaActionClass instancesRespondToSelector:customActionSelector]) { |
31 | 36 | // Initialize with a custom action |
32 | 37 | id (*funcWithCustomAction)(id, SEL, NSString *) = (id(*)( |
33 | 38 | id, SEL, NSString *))[RecaptchaActionClass instanceMethodForSelector:customActionSelector]; |
34 | 39 |
|
35 | | - id<RCAActionProtocol> customAction = funcWithCustomAction([[RecaptchaActionClass alloc] init], |
36 | | - customActionSelector, actionString); |
| 40 | + id<RCAActionProtocol> customAction = |
| 41 | + funcWithCustomAction([RecaptchaActionClass alloc], customActionSelector, actionString); |
37 | 42 | if (customAction) { |
38 | 43 | [recaptchaClient execute:customAction |
39 | 44 | completion:^(NSString *_Nullable token, NSError *_Nullable error) { |
@@ -64,8 +69,15 @@ void FIRRecaptchaGetToken(NSString *siteKey, |
64 | 69 | return; |
65 | 70 | } |
66 | 71 |
|
67 | | - Class RecaptchaClass = NSClassFromString(@"Recaptcha"); |
68 | | - SEL selector = NSSelectorFromString(@"getClientWithSiteKey:completion:"); |
| 72 | + // Why not use `conformsToProtocol`? |
| 73 | + Class RecaptchaClass = NSClassFromString(@"RecaptchaEnterprise.RCARecaptcha"); |
| 74 | + SEL selector = NSSelectorFromString(@"fetchClientWithSiteKey:completion:"); |
| 75 | + if (!RecaptchaClass) { |
| 76 | + // Fall back to attempting to connect with pre-18.7.0 RecaptchaEnterprise. |
| 77 | + RecaptchaClass = NSClassFromString(@"Recaptcha"); |
| 78 | + selector = NSSelectorFromString(@"getClientWithSiteKey:completion:"); |
| 79 | + } |
| 80 | + |
69 | 81 | if (RecaptchaClass && [RecaptchaClass respondsToSelector:selector]) { |
70 | 82 | void (*funcWithoutTimeout)(id, SEL, NSString *, |
71 | 83 | void (^)(id<RCARecaptchaClientProtocol> _Nullable recaptchaClient, |
|
0 commit comments