@@ -166,6 +166,31 @@ - (instancetype)initWithDatabaseID:(model::DatabaseId)databaseID
166166 return self;
167167}
168168
169+ + (instancetype )firestoreForApp : (FIRApp *)app database : (NSString *)database {
170+ if (!app) {
171+ ThrowInvalidArgument (" FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd like "
172+ " to use the default FirebaseApp instance." );
173+ }
174+ if (!database) {
175+ ThrowInvalidArgument (" Database identifier may not be nil. Use '%s' if you want the default "
176+ " database" ,
177+ DatabaseId::kDefault );
178+ }
179+
180+ id <FSTFirestoreMultiDBProvider> provider =
181+ FIR_COMPONENT (FSTFirestoreMultiDBProvider, app.container );
182+ return [provider firestoreForDatabase: database];
183+ }
184+
185+ + (instancetype )firestoreForDatabase : (NSString *)database {
186+ FIRApp *app = [FIRApp defaultApp ];
187+ if (!app) {
188+ ThrowIllegalState (" Failed to get FirebaseApp instance. Please call FirebaseApp.configure() "
189+ " before using Firestore" );
190+ }
191+ return [self firestoreForApp: app database: database];
192+ }
193+
169194- (FIRFirestoreSettings *)settings {
170195 // Disallow mutation of our internal settings
171196 return [_settings copy ];
@@ -512,31 +537,6 @@ @implementation FIRFirestore (Internal)
512537 return _firestore->database_id ();
513538}
514539
515- + (instancetype )firestoreForApp : (FIRApp *)app database : (NSString *)database {
516- if (!app) {
517- ThrowInvalidArgument (" FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd like "
518- " to use the default FirebaseApp instance." );
519- }
520- if (!database) {
521- ThrowInvalidArgument (" Database identifier may not be nil. Use '%s' if you want the default "
522- " database" ,
523- DatabaseId::kDefault );
524- }
525-
526- id <FSTFirestoreMultiDBProvider> provider =
527- FIR_COMPONENT (FSTFirestoreMultiDBProvider, app.container );
528- return [provider firestoreForDatabase: database];
529- }
530-
531- + (instancetype )firestoreForDatabase : (NSString *)database {
532- FIRApp *app = [FIRApp defaultApp ];
533- if (!app) {
534- ThrowIllegalState (" Failed to get FirebaseApp instance. Please call FirebaseApp.configure() "
535- " before using Firestore" );
536- }
537- return [self firestoreForApp: app database: database];
538- }
539-
540540+ (FIRFirestore *)recoverFromFirestore : (std::shared_ptr<Firestore>)firestore {
541541 return (__bridge FIRFirestore *)firestore->extension ();
542542}
0 commit comments