aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Messaging
diff options
context:
space:
mode:
authorGravatar Riz <rsattar@gmail.com>2017-08-07 15:05:21 -0700
committerGravatar GitHub <noreply@github.com>2017-08-07 15:05:21 -0700
commit3e3aa42601c5330f1ec526bb015ce11d669fd4ee (patch)
tree49b7e5283d7fa4d37b0b5a9640e7fc11f3aee8bd /Firebase/Messaging
parentef16282b4ec28bd8e0ae938d92778bf1a3c58392 (diff)
Ensure auto-connect logic is always in main thread (#183)
This addresses #125, where a developer is setting `.shouldEstablishDirectChannel` in a background thread, and getting a main thread sanitization issue in Xcode 9.
Diffstat (limited to 'Firebase/Messaging')
-rw-r--r--Firebase/Messaging/FIRMessaging.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/Firebase/Messaging/FIRMessaging.m b/Firebase/Messaging/FIRMessaging.m
index 96186ce..cde4dc5 100644
--- a/Firebase/Messaging/FIRMessaging.m
+++ b/Firebase/Messaging/FIRMessaging.m
@@ -545,6 +545,13 @@ NSString * const FIRMessagingRegistrationTokenRefreshedNotification =
}
- (void)updateAutomaticClientConnection {
+ if (![NSThread isMainThread]) {
+ // Call this method from the main thread
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self updateAutomaticClientConnection];
+ });
+ return;
+ }
BOOL shouldBeConnected = [self shouldBeConnectedAutomatically];
if (shouldBeConnected && !self.client.isConnected) {
[self.client connectWithHandler:^(NSError *error) {