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 {
4949
5050+ (BOOL )hasBundleIdentifierPrefix : (NSString *)bundleIdentifier inBundles : (NSArray *)bundles {
5151 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]) {
5953 return YES ;
6054 }
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+ }
6165 }
6266 return NO ;
6367}
Original file line number Diff line number Diff line change @@ -95,6 +95,18 @@ - (void)testBundleIdentifierHasPrefixInBundlesForExtension {
9595 [environmentUtilsMock stopMocking ];
9696}
9797
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+
98110- (void )testBundleIdentifierHasPrefixInBundlesNotValidExtension {
99111 id environmentUtilsMock = [OCMockObject mockForClass: [GULAppEnvironmentUtil class ]];
100112 [[[environmentUtilsMock stub ] andReturnValue: @(YES )] isAppExtension ];
You can’t perform that action at this time.
0 commit comments