Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Firebase/Auth/Source/Auth/FIRAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -1884,19 +1884,12 @@ - (BOOL)getUser:(FIRUser *_Nullable *)outUser
return [[FIRAuth alloc] initWithApp:container.app];
};
FIRComponent *authInterop = [FIRComponent componentWithProtocol:@protocol(FIRAuthInterop)
instantiationTiming:FIRInstantiationTimingAlwaysEager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why AlwaysEager?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mimics the previous behaviour removed on the previous line 1897:

https://github.com/firebase/firebase-ios-sdk/pull/4137/files#diff-f33c561b2a3430b947e6da076758c6d9L1897

every time [FIRApp configure] is called, we called [FIRAuth authWithApp:] which instantiated the instance.

The reason it's AlwaysEager and not EagerInDefaultApp is because FIRAuth works with multiple FIRApps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, FIRAuth works with multiple FIRApp s.

dependencies:@[]
creationBlock:authCreationBlock];
return @[authInterop];
}

#pragma mark - FIRCoreConfigurable

+ (void)configureWithApp:(nonnull FIRApp *)app {
// TODO: Evaluate what actually needs to be configured here instead of initializing a full
// instance.
// Ensures the @c FIRAuth instance for a given app gets loaded as soon as the app is ready.
[FIRAuth authWithApp:app];
}

#pragma mark - FIRComponentLifecycleMaintainer

- (void)appWillBeDeleted:(nonnull FIRApp *)app {
Expand Down
46 changes: 23 additions & 23 deletions Firebase/DynamicLinks/FIRDynamicLinks.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,36 @@ + (void)load {
isRequired:NO];
FIRComponentCreationBlock creationBlock =
^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) {
// Don't return an instance when it's not the default app.
if (!container.app.isDefaultApp) {
// Only configure for the default FIRApp.
FDLLog(FDLLogLevelInfo, FDLLogIdentifierSetupNonDefaultApp,
@"Firebase Dynamic Links only "
"works with the default app.");
return nil;
}

// Ensure it's cached so it returns the same instance every time dynamicLinks is called.
*isCacheable = YES;
id<FIRAnalyticsInterop> analytics = FIR_COMPONENT(FIRAnalyticsInterop, container);
return [[FIRDynamicLinks alloc] initWithAnalytics:analytics];
FIRDynamicLinks *dynamicLinks = [[FIRDynamicLinks alloc] initWithAnalytics:analytics];
[dynamicLinks configureDynamicLinks:container.app];
// Check for pending Dynamic Link automatically if enabled, otherwise we expect the developer to
// call strong match FDL API to retrieve a pending link.
if ([FIRDynamicLinks isAutomaticRetrievalEnabled]) {
[dynamicLinks checkForPendingDynamicLink];
}
return dynamicLinks;
};
FIRComponent *dynamicLinksProvider =
[FIRComponent componentWithProtocol:@protocol(FIRDynamicLinksInstanceProvider)
instantiationTiming:FIRInstantiationTimingLazy
instantiationTiming:FIRInstantiationTimingEagerInDefaultApp
dependencies:@[ analyticsDep ]
creationBlock:creationBlock];

return @[ dynamicLinksProvider ];
}

+ (void)configureWithApp:(FIRApp *)app {
if (!app.isDefaultApp) {
// Only configure for the default FIRApp.
FDLLog(FDLLogLevelInfo, FDLLogIdentifierSetupNonDefaultApp,
@"Firebase Dynamic Links only "
"works with the default app.");
return;
}
[[FIRDynamicLinks dynamicLinks] configureDynamicLinks:app];
// check for pending Dynamic Link automatically if enabled
// otherwise we expect developer to call strong match FDL API to retrieve link
if ([FIRDynamicLinks isAutomaticRetrievalEnabled]) {
[[FIRDynamicLinks dynamicLinks] checkForPendingDynamicLink];
}
}

- (void)configureDynamicLinks:(FIRApp *)app {
FIROptions *options = app.options;
NSError *error;
Expand All @@ -181,11 +181,11 @@ - (void)configureDynamicLinks:(FIRApp *)app {
if (!errorDescription) {
// setup FDL if no error detected
urlScheme = options.deepLinkURLScheme ?: [NSBundle mainBundle].bundleIdentifier;
[[FIRDynamicLinks dynamicLinks] setUpWithLaunchOptions:nil
apiKey:options.APIKey
clientID:options.clientID
urlScheme:urlScheme
userDefaults:nil];
[self setUpWithLaunchOptions:nil
apiKey:options.APIKey
clientID:options.clientID
urlScheme:urlScheme
userDefaults:nil];
} else {
error =
[FIRApp errorForSubspecConfigurationFailureWithDomain:kFirebaseDurableDeepLinkErrorDomain
Expand Down
22 changes: 10 additions & 12 deletions Firebase/Messaging/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ + (void)load {
[FIRDependency dependencyWithProtocol:@protocol(FIRAnalyticsInterop) isRequired:NO];
FIRComponentCreationBlock creationBlock =
^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) {
if (!container.app.isDefaultApp) {
// Only start for the default FIRApp.
FIRMessagingLoggerDebug(kFIRMessagingMessageCodeFIRApp001,
@"Firebase Messaging only works with the default app.");
return nil;
}

// Ensure it's cached so it returns the same instance every time messaging is called.
*isCacheable = YES;
id<FIRAnalyticsInterop> analytics = FIR_COMPONENT(FIRAnalyticsInterop, container);
Expand All @@ -233,28 +240,19 @@ + (void)load {
withInstanceID:[FIRInstanceID instanceID]
withUserDefaults:[GULUserDefaults standardUserDefaults]];
[messaging start];
[messaging configureNotificationSwizzlingIfEnabled];
return messaging;
};
FIRComponent *messagingProvider =
[FIRComponent componentWithProtocol:@protocol(FIRMessagingInstanceProvider)
instantiationTiming:FIRInstantiationTimingLazy
instantiationTiming:FIRInstantiationTimingEagerInDefaultApp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change from lazy to eager?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mimics the previous behaviour of configureWithApp:, where Messaging would instantiate itself as soon as configureWithApp: is called.

dependencies:@[ analyticsDep ]
creationBlock:creationBlock];

return @[ messagingProvider ];
}

+ (void)configureWithApp:(FIRApp *)app {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to fix the same for other SDK as well, such as InstanceID, remote config etc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay - IID was fixed in #4030, will be addressing the other SDKs in a separate PR.

if (!app.isDefaultApp) {
// Only configure for the default FIRApp.
FIRMessagingLoggerDebug(kFIRMessagingMessageCodeFIRApp001,
@"Firebase Messaging only works with the default app.");
return;
}
[[FIRMessaging messaging] configureMessaging:app];
}

- (void)configureMessaging:(FIRApp *)app {
- (void)configureNotificationSwizzlingIfEnabled {
// Swizzle remote-notification-related methods (app delegate and UNUserNotificationCenter)
if ([FIRMessagingRemoteNotificationsProxy canSwizzleMethods]) {
NSString *docsURLString = @"https://firebase.google.com/docs/cloud-messaging/ios/client"
Expand Down