diff --git a/FirebaseDatabase/CHANGELOG.md b/FirebaseDatabase/CHANGELOG.md index 7ee5692d4f0..7df20ba497e 100644 --- a/FirebaseDatabase/CHANGELOG.md +++ b/FirebaseDatabase/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased +- [fixed] Fix temporary disconnects when the app goes inactive. The issue was + introduced in 10.27.0. (#13529) + # 11.0.0 - [removed] **Breaking change**: The deprecated `FirebaseDatabaseSwift` module has been removed. See diff --git a/FirebaseDatabase/Sources/Core/FPersistentConnection.m b/FirebaseDatabase/Sources/Core/FPersistentConnection.m index 8c22814df00..f07ee977246 100644 --- a/FirebaseDatabase/Sources/Core/FPersistentConnection.m +++ b/FirebaseDatabase/Sources/Core/FPersistentConnection.m @@ -34,11 +34,9 @@ #import "FirebaseDatabase/Sources/Utilities/FUtilities.h" #import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleCallbackStatus.h" #import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleOnDisconnect.h" -#if TARGET_OS_WATCH -#import -#else +#if !TARGET_OS_WATCH #import -#endif // TARGET_OS_WATCH +#endif // !TARGET_OS_WATCH #import #import @@ -168,7 +166,6 @@ - (id)initWithRepoInfo:(FRepoInfo *)repoInfo retryExponent:kPersistentConnReconnectMultiplier jitterFactor:0.7]; - [self setupNotifications]; // Make sure we don't actually connect until open is called [self interruptForReason:kFInterruptReasonWaitingForOpen]; } @@ -553,29 +550,6 @@ - (void)openNetworkConnectionWithContext: [self.realtime open]; } -- (void)enteringForeground { - dispatch_async(self.dispatchQueue, ^{ - // Reset reconnect delay - [self.retryHelper signalSuccess]; - if (self->connectionState == ConnectionStateDisconnected) { - [self tryScheduleReconnect]; - } - }); -} - -- (void)setupNotifications { -#if TARGET_OS_WATCH - __weak FPersistentConnection *weakSelf = self; - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center addObserverForName:WKApplicationWillEnterForegroundNotification - object:nil - queue:nil - usingBlock:^(NSNotification *_Nonnull note) { - [weakSelf enteringForeground]; - }]; -#endif // TARGET_OS_WATCH -} - - (void)sendAuthAndRestoreStateAfterComplete:(BOOL)restoreStateAfterComplete { NSAssert([self connected], @"Must be connected to send auth"); NSAssert(self.authToken != nil, diff --git a/FirebaseDatabase/Sources/Realtime/FWebSocketConnection.m b/FirebaseDatabase/Sources/Realtime/FWebSocketConnection.m index 6aa9d7365e5..078fbb06ef6 100644 --- a/FirebaseDatabase/Sources/Realtime/FWebSocketConnection.m +++ b/FirebaseDatabase/Sources/Realtime/FWebSocketConnection.m @@ -110,27 +110,6 @@ - (instancetype)initWith:(FRepoInfo *)repoInfo NSURLSessionWebSocketTask *task = [session webSocketTaskWithRequest:req]; self.webSocketTask = task; - -#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION || TARGET_OS_MACCATALYST - NSString *resignName = UIApplicationWillResignActiveNotification; -#elif TARGET_OS_OSX - NSString *resignName = NSApplicationWillResignActiveNotification; -#elif TARGET_OS_WATCH - NSString *resignName = WKApplicationWillResignActiveNotification; -#elif -#error("missing platform") -#endif - [[NSNotificationCenter defaultCenter] - addObserverForName:resignName - object:nil - queue:opQueue - usingBlock:^(NSNotification *_Nonnull note) { - FFLog(@"I-RDB083015", - @"Received notification that application " - @"will resign, " - @"closing web socket."); - [self onClosed]; - }]; } } return self;