aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Messaging/FIRMessagingPubSub.m
diff options
context:
space:
mode:
authorGravatar Chen Liang <chliang@google.com>2018-03-30 11:41:38 -0700
committerGravatar GitHub <noreply@github.com>2018-03-30 11:41:38 -0700
commit653aea7b50247bb0f6a7e8e1b4ab782553849f74 (patch)
tree0e2b9d8d660aee63a9a4659203e5ca9c1b692c61 /Firebase/Messaging/FIRMessagingPubSub.m
parentcdd855423a79ed0191b37b7dcac2df9fb342c9a5 (diff)
Adding a new topic subscription/unsubcription with completion handler method (#1001)
* add new topic subscription/unsubscription method with handler
Diffstat (limited to 'Firebase/Messaging/FIRMessagingPubSub.m')
-rw-r--r--Firebase/Messaging/FIRMessagingPubSub.m28
1 files changed, 10 insertions, 18 deletions
diff --git a/Firebase/Messaging/FIRMessagingPubSub.m b/Firebase/Messaging/FIRMessagingPubSub.m
index 74a5292..09491b4 100644
--- a/Firebase/Messaging/FIRMessagingPubSub.m
+++ b/Firebase/Messaging/FIRMessagingPubSub.m
@@ -60,8 +60,7 @@ static NSString *const kPendingSubscriptionsListKey =
_FIRMessagingDevAssert([token length], @"FIRMessaging error no token specified");
_FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified");
if (!self.client) {
- handler(FIRMessagingTopicOperationResultError,
- [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubFIRMessagingNotSetup]);
+ handler([NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubFIRMessagingNotSetup]);
return;
}
@@ -75,8 +74,7 @@ static NSString *const kPendingSubscriptionsListKey =
if (![[self class] isValidTopicWithPrefix:topic]) {
FIRMessagingLoggerError(kFIRMessagingMessageCodePubSub000,
@"Invalid FIRMessaging Pubsub topic %@", topic);
- handler(FIRMessagingTopicOperationResultError,
- [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubInvalidTopic]);
+ handler([NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubInvalidTopic]);
return;
}
@@ -93,11 +91,9 @@ static NSString *const kPendingSubscriptionsListKey =
topic:topic
options:options
shouldDelete:NO
- handler:
- ^void(FIRMessagingTopicOperationResult result, NSError * error) {
-
- handler(result, error);
- }];
+ handler:^void(NSError *error) {
+ handler(error);
+ }];
}
- (void)unsubscribeWithToken:(NSString *)token
@@ -108,8 +104,7 @@ static NSString *const kPendingSubscriptionsListKey =
_FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified");
if (!self.client) {
- handler(FIRMessagingTopicOperationResultError,
- [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubFIRMessagingNotSetup]);
+ handler([NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubFIRMessagingNotSetup]);
return;
}
@@ -122,8 +117,7 @@ static NSString *const kPendingSubscriptionsListKey =
if (![[self class] isValidTopicWithPrefix:topic]) {
FIRMessagingLoggerError(kFIRMessagingMessageCodePubSub002,
@"Invalid FIRMessaging Pubsub topic %@", topic);
- handler(FIRMessagingTopicOperationResultError,
- [NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubInvalidTopic]);
+ handler([NSError errorWithFCMErrorCode:kFIRMessagingErrorCodePubSubInvalidTopic]);
return;
}
if (![self verifyPubSubOptions:options]) {
@@ -139,11 +133,9 @@ static NSString *const kPendingSubscriptionsListKey =
topic:topic
options:options
shouldDelete:YES
- handler:
- ^void(FIRMessagingTopicOperationResult result, NSError * error) {
-
- handler(result, error);
- }];
+ handler:^void(NSError *error) {
+ handler(error);
+ }];
}
- (void)subscribeToTopic:(NSString *)topic