aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Firebase/Messaging/FIRMessagingClient.m26
-rw-r--r--Firebase/Messaging/FIRMessagingRegistrar.m6
2 files changed, 13 insertions, 19 deletions
diff --git a/Firebase/Messaging/FIRMessagingClient.m b/Firebase/Messaging/FIRMessagingClient.m
index d36778d..0bfb5a8 100644
--- a/Firebase/Messaging/FIRMessagingClient.m
+++ b/Firebase/Messaging/FIRMessagingClient.m
@@ -185,7 +185,6 @@ static NSUInteger FIRMessagingServerPort() {
handler(error);
};
- [self.registrar tryToLoadValidCheckinInfo];
[self.registrar updateSubscriptionToTopic:topic
withToken:token
options:options
@@ -266,7 +265,6 @@ static NSUInteger FIRMessagingServerPort() {
}
self.lastDisconnectedTimestamp = FIRMessagingCurrentTimestampInMilliseconds();
self.connectHandler = handler;
- [self.registrar tryToLoadValidCheckinInfo];
[self connect];
}
@@ -279,21 +277,17 @@ static NSUInteger FIRMessagingServerPort() {
}
self.stayConnected = YES;
- BOOL isRegistrationComplete = [self.registrar hasValidCheckinInfo];
-
- if (!isRegistrationComplete) {
- if (![self.registrar tryToLoadValidCheckinInfo]) {
- // Checkin info is not available. This may be due to the checkin still being fetched.
- if (self.connectHandler) {
- NSError *error = [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodeMissingDeviceID];
- self.connectHandler(error);
- }
- FIRMessagingLoggerDebug(kFIRMessagingMessageCodeClient009,
- @"Failed to connect to MCS. No deviceID and secret found.");
- // Return for now. If checkin is, in fact, retrieved, the
- // |kFIRMessagingCheckinFetchedNotification| will be fired.
- return;
+ if (![self.registrar tryToLoadValidCheckinInfo]) {
+ // Checkin info is not available. This may be due to the checkin still being fetched.
+ if (self.connectHandler) {
+ NSError *error = [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodeMissingDeviceID];
+ self.connectHandler(error);
}
+ FIRMessagingLoggerDebug(kFIRMessagingMessageCodeClient009,
+ @"Failed to connect to MCS. No deviceID and secret found.");
+ // Return for now. If checkin is, in fact, retrieved, the
+ // |kFIRMessagingCheckinFetchedNotification| will be fired.
+ return;
}
[self setupConnectionAndConnect];
}
diff --git a/Firebase/Messaging/FIRMessagingRegistrar.m b/Firebase/Messaging/FIRMessagingRegistrar.m
index bb1e9ad..999666c 100644
--- a/Firebase/Messaging/FIRMessagingRegistrar.m
+++ b/Firebase/Messaging/FIRMessagingRegistrar.m
@@ -45,6 +45,8 @@
self = [super init];
if (self) {
_checkinService = [[FIRMessagingCheckinService alloc] init];
+ // TODO(chliangGoogle): Merge pubsubRegistrar with Registrar as it is hard to track how many
+ // checkinService instances by separating classes too often.
_pubsubRegistrar = [[FIRMessagingPubSubRegistrar alloc] initWithCheckinService:_checkinService];
}
return self;
@@ -53,9 +55,7 @@
#pragma mark - Checkin
- (BOOL)tryToLoadValidCheckinInfo {
- if (![self.checkinService hasValidCheckinInfo]) {
- [self.checkinService tryToLoadPrefetchedCheckinPreferences];
- }
+ [self.checkinService tryToLoadPrefetchedCheckinPreferences];
return [self.checkinService hasValidCheckinInfo];
}