Skip to content

Commit 936ddf4

Browse files
authored
Fix temporary disconnect when app goes inactive (#13564)
1 parent d1b950f commit 936ddf4

File tree

3 files changed

+6
-49
lines changed

3 files changed

+6
-49
lines changed

FirebaseDatabase/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- [fixed] Fix temporary disconnects when the app goes inactive. The issue was
3+
introduced in 10.27.0. (#13529)
4+
15
# 11.0.0
26
- [removed] **Breaking change**: The deprecated `FirebaseDatabaseSwift`
37
module has been removed. See

FirebaseDatabase/Sources/Core/FPersistentConnection.m

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
#import "FirebaseDatabase/Sources/Utilities/FUtilities.h"
3535
#import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleCallbackStatus.h"
3636
#import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleOnDisconnect.h"
37-
#if TARGET_OS_WATCH
38-
#import <WatchKit/WatchKit.h>
39-
#else
37+
#if !TARGET_OS_WATCH
4038
#import <SystemConfiguration/SystemConfiguration.h>
41-
#endif // TARGET_OS_WATCH
39+
#endif // !TARGET_OS_WATCH
4240
#import <dlfcn.h>
4341
#import <netinet/in.h>
4442

@@ -168,7 +166,6 @@ - (id)initWithRepoInfo:(FRepoInfo *)repoInfo
168166
retryExponent:kPersistentConnReconnectMultiplier
169167
jitterFactor:0.7];
170168

171-
[self setupNotifications];
172169
// Make sure we don't actually connect until open is called
173170
[self interruptForReason:kFInterruptReasonWaitingForOpen];
174171
}
@@ -553,29 +550,6 @@ - (void)openNetworkConnectionWithContext:
553550
[self.realtime open];
554551
}
555552

556-
- (void)enteringForeground {
557-
dispatch_async(self.dispatchQueue, ^{
558-
// Reset reconnect delay
559-
[self.retryHelper signalSuccess];
560-
if (self->connectionState == ConnectionStateDisconnected) {
561-
[self tryScheduleReconnect];
562-
}
563-
});
564-
}
565-
566-
- (void)setupNotifications {
567-
#if TARGET_OS_WATCH
568-
__weak FPersistentConnection *weakSelf = self;
569-
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
570-
[center addObserverForName:WKApplicationWillEnterForegroundNotification
571-
object:nil
572-
queue:nil
573-
usingBlock:^(NSNotification *_Nonnull note) {
574-
[weakSelf enteringForeground];
575-
}];
576-
#endif // TARGET_OS_WATCH
577-
}
578-
579553
- (void)sendAuthAndRestoreStateAfterComplete:(BOOL)restoreStateAfterComplete {
580554
NSAssert([self connected], @"Must be connected to send auth");
581555
NSAssert(self.authToken != nil,

FirebaseDatabase/Sources/Realtime/FWebSocketConnection.m

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,6 @@ - (instancetype)initWith:(FRepoInfo *)repoInfo
110110
NSURLSessionWebSocketTask *task =
111111
[session webSocketTaskWithRequest:req];
112112
self.webSocketTask = task;
113-
114-
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION || TARGET_OS_MACCATALYST
115-
NSString *resignName = UIApplicationWillResignActiveNotification;
116-
#elif TARGET_OS_OSX
117-
NSString *resignName = NSApplicationWillResignActiveNotification;
118-
#elif TARGET_OS_WATCH
119-
NSString *resignName = WKApplicationWillResignActiveNotification;
120-
#elif
121-
#error("missing platform")
122-
#endif
123-
[[NSNotificationCenter defaultCenter]
124-
addObserverForName:resignName
125-
object:nil
126-
queue:opQueue
127-
usingBlock:^(NSNotification *_Nonnull note) {
128-
FFLog(@"I-RDB083015",
129-
@"Received notification that application "
130-
@"will resign, "
131-
@"closing web socket.");
132-
[self onClosed];
133-
}];
134113
}
135114
}
136115
return self;

0 commit comments

Comments
 (0)