From 486078303db7ae462b4c397e8443b5016be9165c Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 13 Nov 2023 09:57:05 +0000 Subject: [PATCH] fix(storage): set emulator once for each bucket it is required --- .../ios/Classes/FLTFirebaseStoragePlugin.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m index 2001cca02c7b..e5230b2c7ce4 100644 --- a/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m +++ b/packages/firebase_storage/firebase_storage/ios/Classes/FLTFirebaseStoragePlugin.m @@ -68,7 +68,7 @@ @interface FLTFirebaseStoragePlugin () @implementation FLTFirebaseStoragePlugin { NSMutableDictionary *> *_tasks; dispatch_queue_t _callbackQueue; - bool hasEmulatorBooted; + NSMutableDictionary *_emulatorBooted; NSObject *_binaryMessenger; NSMutableDictionary *_eventChannels; NSMutableDictionary *> *_streamHandlers; @@ -97,7 +97,7 @@ - (instancetype)init:(NSObject *)messenger { dictionary]; _callbackQueue = dispatch_queue_create("io.flutter.plugins.firebase.storage", DISPATCH_QUEUE_SERIAL); - hasEmulatorBooted = false; + _emulatorBooted = [[NSMutableDictionary alloc] init]; _binaryMessenger = messenger; _eventChannels = [NSMutableDictionary dictionary]; _streamHandlers = [NSMutableDictionary dictionary]; @@ -242,9 +242,11 @@ - (void)useStorageEmulatorApp:(PigeonStorageFirebaseApp *)app port:(NSNumber *)port completion:(void (^)(FlutterError *_Nullable))completion { FIRStorage *storage = [self getFIRStorageFromAppNameFromPigeon:app]; - if (hasEmulatorBooted == false) { + NSNumber *emulatorKey = _emulatorBooted[app.bucket]; + + if (emulatorKey == nil) { [storage useEmulatorWithHost:host port:[port integerValue]]; - hasEmulatorBooted = true; + [_emulatorBooted setObject:@(YES) forKey:app.bucket]; } completion(nil); }