File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -49,15 +49,19 @@ + (NSArray *)relevantURLSchemes {
49
49
50
50
+ (BOOL )hasBundleIdentifierPrefix : (NSString *)bundleIdentifier inBundles : (NSArray *)bundles {
51
51
for (NSBundle *bundle in bundles) {
52
- // This allows app extensions that have the app's bundle as their prefix to pass this test.
53
- NSString *applicationBundleIdentifier =
54
- [GULAppEnvironmentUtil isAppExtension ]
55
- ? [self bundleIdentifierByRemovingLastPartFrom: bundle.bundleIdentifier]
56
- : bundle.bundleIdentifier ;
57
-
58
- if ([applicationBundleIdentifier isEqualToString: bundleIdentifier]) {
52
+ if ([bundle.bundleIdentifier isEqualToString: bundleIdentifier]) {
59
53
return YES ;
60
54
}
55
+
56
+ if ([GULAppEnvironmentUtil isAppExtension ]) {
57
+ // A developer could be using the same `FIROptions` for both their app and extension. Since
58
+ // extensions have a suffix added to the bundleID, we consider a matching prefix as valid.
59
+ NSString *appBundleIDFromExtension =
60
+ [self bundleIdentifierByRemovingLastPartFrom: bundle.bundleIdentifier];
61
+ if ([appBundleIDFromExtension isEqualToString: bundleIdentifier]) {
62
+ return YES ;
63
+ }
64
+ }
61
65
}
62
66
return NO ;
63
67
}
Original file line number Diff line number Diff line change @@ -95,6 +95,18 @@ - (void)testBundleIdentifierHasPrefixInBundlesForExtension {
95
95
[environmentUtilsMock stopMocking ];
96
96
}
97
97
98
+ - (void )testBundleIdentifierExistsInBundlesForExtensions_exactMatch {
99
+ id environmentUtilsMock = [OCMockObject mockForClass: [GULAppEnvironmentUtil class ]];
100
+ [[[environmentUtilsMock stub ] andReturnValue: @(YES )] isAppExtension ];
101
+
102
+ // Mock bundle should have what app extension has, the extension bundle ID.
103
+ [OCMStub ([self .mockBundle bundleIdentifier ]) andReturn: @" com.google.test.someextension" ];
104
+ XCTAssertTrue ([FIRBundleUtil hasBundleIdentifierPrefix: @" com.google.test.someextension"
105
+ inBundles: @[ self .mockBundle ]]);
106
+
107
+ [environmentUtilsMock stopMocking ];
108
+ }
109
+
98
110
- (void )testBundleIdentifierHasPrefixInBundlesNotValidExtension {
99
111
id environmentUtilsMock = [OCMockObject mockForClass: [GULAppEnvironmentUtil class ]];
100
112
[[[environmentUtilsMock stub ] andReturnValue: @(YES )] isAppExtension ];
You can’t perform that action at this time.
0 commit comments