Jelajahi Sumber

[v11] Remove `configureWithApp:` API in FIRLibrary protocol (#13147)

Nick Cooke 1 tahun lalu
induk
melakukan
5ccf3ae8b9

+ 0 - 5
FirebaseCore/Extension/FIRLibrary.h

@@ -32,11 +32,6 @@ NS_SWIFT_NAME(Library)
 /// FirebaseApp and participate in dependency resolution and injection.
 + (NSArray<FIRComponent *> *)componentsToRegister;
 
-@optional
-/// Implement this method if the library needs notifications for lifecycle events. This method is
-/// called when the developer calls `FirebaseApp.configure()`.
-+ (void)configureWithApp:(FIRApp *)app;
-
 @end
 
 NS_ASSUME_NONNULL_END

+ 0 - 23
FirebaseCore/Sources/FIRApp.m

@@ -84,12 +84,6 @@ NSString *const kFirebaseCoreErrorDomain = @"com.firebase.core";
  */
 static NSString *const kPlistURL = @"https://console.firebase.google.com/";
 
-/**
- * An array of all classes that registered as `FIRCoreConfigurable` in order to receive lifecycle
- * events from Core.
- */
-static NSMutableArray<Class<FIRLibrary>> *sRegisteredAsConfigurable;
-
 @interface FIRApp ()
 
 #ifdef DEBUG
@@ -450,14 +444,6 @@ static FIRApp *sDefaultApp;
   [[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppReadyToConfigureSDKNotification
                                                       object:self
                                                     userInfo:appInfoDict];
-
-  // This is the new way of sending information to SDKs.
-  // TODO: Do we want this on a background thread, maybe?
-  @synchronized(self) {
-    for (Class<FIRLibrary> library in sRegisteredAsConfigurable) {
-      [library configureWithApp:app];
-    }
-  }
 }
 
 + (NSError *)errorForMissingOptions {
@@ -522,15 +508,6 @@ static FIRApp *sDefaultApp;
   }
 
   [FIRComponentContainer registerAsComponentRegistrant:library];
-  if ([(Class)library respondsToSelector:@selector(configureWithApp:)]) {
-    static dispatch_once_t onceToken;
-    dispatch_once(&onceToken, ^{
-      sRegisteredAsConfigurable = [[NSMutableArray alloc] init];
-    });
-    @synchronized(self) {
-      [sRegisteredAsConfigurable addObject:library];
-    }
-  }
   [self registerLibrary:name withVersion:version];
 }
 

+ 19 - 21
FirebaseInAppMessaging/Sources/FIRInAppMessaging.m

@@ -53,38 +53,36 @@ static BOOL _autoBootstrapOnFIRAppInit = YES;
       ^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) {
     // Ensure it's cached so it returns the same instance every time fiam is called.
     *isCacheable = YES;
+
+    // Only configure for the default FIRApp.
+    if (!container.app.isDefaultApp) {
+      FIRLogError(kFIRLoggerInAppMessaging, @"I-IAM170000",
+                  @"In-App Messaging must be used with the default Firebase app.");
+      return nil;
+    }
+
     id<FIRAnalyticsInterop> analytics = FIR_COMPONENT(FIRAnalyticsInterop, container);
     FIRInstallations *installations = [FIRInstallations installationsWithApp:container.app];
+
+    if (_autoBootstrapOnFIRAppInit) {
+      FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170002",
+                  @"Auto bootstrap Firebase in-app messaging SDK");
+      [FIRInAppMessaging bootstrapIAMFromFIRApp:container.app];
+    } else {
+      FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170003",
+                  @"No auto bootstrap Firebase in-app messaging SDK");
+    }
+
     return [[FIRInAppMessaging alloc] initWithAnalytics:analytics installations:installations];
   };
   FIRComponent *fiamProvider =
       [FIRComponent componentWithProtocol:@protocol(FIRInAppMessagingInstanceProvider)
-                      instantiationTiming:FIRInstantiationTimingLazy
+                      instantiationTiming:FIRInstantiationTimingEagerInDefaultApp
                             creationBlock:creationBlock];
 
   return @[ fiamProvider ];
 }
 
-+ (void)configureWithApp:(FIRApp *)app {
-  if (!app.isDefaultApp) {
-    // Only configure for the default FIRApp.
-    FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170000",
-                @"Firebase InAppMessaging only works with the default app.");
-    return;
-  }
-
-  FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170001",
-              @"Got notification for kFIRAppReadyToConfigureSDKNotification");
-  if (_autoBootstrapOnFIRAppInit) {
-    FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170002",
-                @"Auto bootstrap Firebase in-app messaging SDK");
-    [self bootstrapIAMFromFIRApp:app];
-  } else {
-    FIRLogDebug(kFIRLoggerInAppMessaging, @"I-IAM170003",
-                @"No auto bootstrap Firebase in-app messaging SDK");
-  }
-}
-
 - (instancetype)initWithAnalytics:(id<FIRAnalyticsInterop>)analytics
                     installations:(FIRInstallations *)installations {
   if (self = [super init]) {