aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Chen Liang <chliang@google.com>2018-06-19 15:59:04 -0700
committerGravatar GitHub <noreply@github.com>2018-06-19 15:59:04 -0700
commit468cb9151791a313d44e382976e6aa22fec45db4 (patch)
tree11080590af984ed57d8024db5f603ef33afecef7 /Firebase
parent69ccd6d8b18b833acfd47ce251f05e94000e6ff5 (diff)
add a warning message that the topic operation is suspended without a token (#1427)
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Messaging/FIRMessaging.m73
1 files changed, 37 insertions, 36 deletions
diff --git a/Firebase/Messaging/FIRMessaging.m b/Firebase/Messaging/FIRMessaging.m
index efafcc2..100c18a 100644
--- a/Firebase/Messaging/FIRMessaging.m
+++ b/Firebase/Messaging/FIRMessaging.m
@@ -680,6 +680,9 @@ NSString *const kFIRMessagingPlistAutoInitEnabled =
#pragma mark - Topics
+ (NSString *)normalizeTopic:(NSString *)topic {
+ if (!topic.length) {
+ return nil;
+ }
if (![FIRMessagingPubSub hasTopicsPrefix:topic]) {
topic = [FIRMessagingPubSub addPrefixToTopic:topic];
}
@@ -695,25 +698,24 @@ NSString *const kFIRMessagingPlistAutoInitEnabled =
- (void)subscribeToTopic:(NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion {
- if (topic.length) {
- NSString *normalizeTopic = [[self class ] normalizeTopic:topic];
- if ([FIRMessagingPubSub hasTopicsPrefix:topic]) {
- FIRMessagingLoggerWarn(kFIRMessagingMessageCodeTopicFormatIsDeprecated,
- @"Format '%@' is deprecated. Only '%@' should be used in "
- @"subscribeToTopic.", topic,
- [FIRMessagingPubSub removePrefixFromTopic:topic]);
- }
- if (normalizeTopic.length) {
- [self.pubsub subscribeToTopic:normalizeTopic handler:completion];
- } else {
- FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging009,
- @"Cannot parse topic name %@. Will not subscribe.", topic);
- }
- } else {
- FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging010,
- @"Cannot subscribe to topic: %@ with token: %@", topic,
- self.defaultFcmToken);
+ if ([FIRMessagingPubSub hasTopicsPrefix:topic]) {
+ FIRMessagingLoggerWarn(kFIRMessagingMessageCodeTopicFormatIsDeprecated,
+ @"Format '%@' is deprecated. Only '%@' should be used in "
+ @"subscribeToTopic.",
+ topic, [FIRMessagingPubSub removePrefixFromTopic:topic]);
+ }
+ if (!self.defaultFcmToken.length) {
+ FIRMessagingLoggerWarn(kFIRMessagingMessageCodeMessaging010,
+ @"The subscription operation is suspended because you don't have a "
+ @"token. The operation will resume once you get an FCM token.");
+ }
+ NSString *normalizeTopic = [[self class] normalizeTopic:topic];
+ if (normalizeTopic.length) {
+ [self.pubsub subscribeToTopic:normalizeTopic handler:completion];
+ return;
}
+ FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging009,
+ @"Cannot parse topic name %@. Will not subscribe.", topic);
}
- (void)unsubscribeFromTopic:(NSString *)topic {
@@ -722,25 +724,24 @@ NSString *const kFIRMessagingPlistAutoInitEnabled =
- (void)unsubscribeFromTopic:(NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion {
- if (topic.length) {
- NSString *normalizeTopic = [[self class] normalizeTopic:topic];
- if ([FIRMessagingPubSub hasTopicsPrefix:topic]) {
- FIRMessagingLoggerWarn(kFIRMessagingMessageCodeTopicFormatIsDeprecated,
- @"Format '%@' is deprecated. Only '%@' should be used in "
- @"unsubscribeFromTopic.", topic,
- [FIRMessagingPubSub removePrefixFromTopic:topic]);
- }
- if (normalizeTopic.length) {
- [self.pubsub unsubscribeFromTopic:normalizeTopic handler:completion];
- } else {
- FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging011,
- @"Cannot parse topic name %@. Will not unsubscribe.", topic);
- }
- } else {
- FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging012,
- @"Cannot unsubscribe to topic: %@ with token: %@", topic,
- self.defaultFcmToken);
+ if ([FIRMessagingPubSub hasTopicsPrefix:topic]) {
+ FIRMessagingLoggerWarn(kFIRMessagingMessageCodeTopicFormatIsDeprecated,
+ @"Format '%@' is deprecated. Only '%@' should be used in "
+ @"unsubscribeFromTopic.",
+ topic, [FIRMessagingPubSub removePrefixFromTopic:topic]);
+ }
+ if (!self.defaultFcmToken.length) {
+ FIRMessagingLoggerWarn(kFIRMessagingMessageCodeMessaging012,
+ @"The unsubscription operation is suspended because you don't have a "
+ @"token. The operation will resume once you get an FCM token.");
+ }
+ NSString *normalizeTopic = [[self class] normalizeTopic:topic];
+ if (normalizeTopic.length) {
+ [self.pubsub unsubscribeFromTopic:normalizeTopic handler:completion];
+ return;
}
+ FIRMessagingLoggerError(kFIRMessagingMessageCodeMessaging011,
+ @"Cannot parse topic name %@. Will not unsubscribe.", topic);
}
#pragma mark - Send