|
20 | 20 | #import "FirebaseCore/Extension/FIRComponent.h"
|
21 | 21 | #import "FirebaseCore/Extension/FIRLibrary.h"
|
22 | 22 | #import "FirebaseCore/Extension/FIRLogger.h"
|
| 23 | +#import "FirebaseCore/Extension/FIROptionsInternal.h" |
23 | 24 |
|
24 | 25 | NS_ASSUME_NONNULL_BEGIN
|
25 | 26 |
|
@@ -61,7 +62,18 @@ + (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass
|
61 | 62 | #pragma mark - Internal Initialization
|
62 | 63 |
|
63 | 64 | - (instancetype)initWithApp:(FIRApp *)app {
|
64 |
| - return [self initWithApp:app registrants:sFIRComponentRegistrants]; |
| 65 | + NSMutableSet<Class> *componentRegistrants = sFIRComponentRegistrants; |
| 66 | + // If the app being created is for the ARCore SDK, remove the App Check |
| 67 | + // component (if it exists) since it does not support App Check. |
| 68 | + if ([self isAppForARCore:app]) { |
| 69 | + Class klass = NSClassFromString(@"FIRAppCheckComponent"); |
| 70 | + if (klass && [sFIRComponentRegistrants containsObject:klass]) { |
| 71 | + componentRegistrants = [componentRegistrants mutableCopy]; |
| 72 | + [componentRegistrants removeObject:klass]; |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + return [self initWithApp:app registrants:componentRegistrants]; |
65 | 77 | }
|
66 | 78 |
|
67 | 79 | - (instancetype)initWithApp:(FIRApp *)app registrants:(NSMutableSet<Class> *)allRegistrants {
|
@@ -214,6 +226,26 @@ - (void)removeAllComponents {
|
214 | 226 | }
|
215 | 227 | }
|
216 | 228 |
|
| 229 | +#pragma mark - Helpers |
| 230 | + |
| 231 | +- (BOOL)isAppForARCore:(FIRApp *)app { |
| 232 | + // First, check if the app name matches that of the one used by ARCore. |
| 233 | + if ([app.name isEqualToString:@"ARCoreFIRApp"]) { |
| 234 | + // Second, check if the app's gcmSenderID matches that of ARCore. This |
| 235 | + // prevents false positives in the unlikely event a 3P Firebase app is |
| 236 | + // named `ARCoreFIRApp`. |
| 237 | + const char *p1 = "406756"; |
| 238 | + const char *p2 = "893798"; |
| 239 | + const char gcmSenderIDKey[27] = {p1[0], p2[0], p1[1], p2[1], p1[2], p2[2], p1[3], |
| 240 | + p2[3], p1[4], p2[4], p1[5], p2[5], p1[6], p2[6], |
| 241 | + p1[7], p2[7], p1[8], p2[8], p1[9], p2[9], p1[10], |
| 242 | + p2[10], p1[11], p2[11], p1[12], p2[12], '\0'}; |
| 243 | + NSString *gcmSenderID = [NSString stringWithUTF8String:gcmSenderIDKey]; |
| 244 | + return [app.options.GCMSenderID isEqualToString:gcmSenderID]; |
| 245 | + } |
| 246 | + return NO; |
| 247 | +} |
| 248 | + |
217 | 249 | @end
|
218 | 250 |
|
219 | 251 | NS_ASSUME_NONNULL_END
|
0 commit comments