From 6a769d5a14d31a33beece8e4221af10932fe12ee Mon Sep 17 00:00:00 2001 From: chliangGoogle Date: Thu, 12 Apr 2018 21:18:20 -0700 Subject: [PATCH 1/3] option should be nullable for subscription --- Firebase/Messaging/FIRMessagingPubSub.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firebase/Messaging/FIRMessagingPubSub.m b/Firebase/Messaging/FIRMessagingPubSub.m index 09491b439bd..9d6598c7b4d 100644 --- a/Firebase/Messaging/FIRMessagingPubSub.m +++ b/Firebase/Messaging/FIRMessagingPubSub.m @@ -55,7 +55,7 @@ - (instancetype)initWithClient:(FIRMessagingClient *)client { - (void)subscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(NSDictionary *)options + options:(nullable NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler { _FIRMessagingDevAssert([token length], @"FIRMessaging error no token specified"); _FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified"); @@ -98,7 +98,7 @@ - (void)subscribeWithToken:(NSString *)token - (void)unsubscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(NSDictionary *)options + options:(nullable NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler { _FIRMessagingDevAssert([token length], @"FIRMessaging error no token specified"); _FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified"); From 80f16c65e49d63779d5f89f152d4cfc342edbeac Mon Sep 17 00:00:00 2001 From: chliangGoogle Date: Thu, 12 Apr 2018 21:23:14 -0700 Subject: [PATCH 2/3] also remove nonnull warning when forcing a nil object for testing --- Example/Messaging/Tests/FIRMessagingServiceTest.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Example/Messaging/Tests/FIRMessagingServiceTest.m b/Example/Messaging/Tests/FIRMessagingServiceTest.m index 9afdced12ae..073adad1a29 100644 --- a/Example/Messaging/Tests/FIRMessagingServiceTest.m +++ b/Example/Messaging/Tests/FIRMessagingServiceTest.m @@ -146,12 +146,15 @@ - (void)testSubscribeWithInvalidTopic { XCTestExpectation *exceptionExpectation = [self expectationWithDescription:@"Should throw exception for invalid token"]; @try { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" [messaging.pubsub subscribeWithToken:@"abcdef1234" topic:nil options:nil handler:^(NSError *error) { XCTFail(@"Should not invoke the handler"); }]; +#pragma clang diagnostic pop } @catch (NSException *exception) { [exceptionExpectation fulfill]; @@ -169,12 +172,15 @@ - (void)testUnsubscribeWithInvalidTopic { XCTestExpectation *exceptionExpectation = [self expectationWithDescription:@"Should throw exception for invalid token"]; @try { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" [messaging.pubsub unsubscribeWithToken:@"abcdef1234" topic:nil options:nil handler:^(NSError *error) { XCTFail(@"Should not invoke the handler"); }]; +#pragma clang diagnostic pop } @catch (NSException *exception) { [exceptionExpectation fulfill]; From 38da0b19b4d60dbdb2af461fe7243dd51c563775 Mon Sep 17 00:00:00 2001 From: chliangGoogle Date: Fri, 13 Apr 2018 10:57:04 -0700 Subject: [PATCH 3/3] should declare nullable in the header; --- Firebase/Messaging/FIRMessagingPubSub.h | 4 ++-- Firebase/Messaging/FIRMessagingPubSub.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Firebase/Messaging/FIRMessagingPubSub.h b/Firebase/Messaging/FIRMessagingPubSub.h index b2498660000..1c615d18d48 100644 --- a/Firebase/Messaging/FIRMessagingPubSub.h +++ b/Firebase/Messaging/FIRMessagingPubSub.h @@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)subscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(NSDictionary *)options + options:(nullable NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler; /** @@ -92,7 +92,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)unsubscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(NSDictionary *)options + options:(nullable NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler; /** diff --git a/Firebase/Messaging/FIRMessagingPubSub.m b/Firebase/Messaging/FIRMessagingPubSub.m index 9d6598c7b4d..09491b439bd 100644 --- a/Firebase/Messaging/FIRMessagingPubSub.m +++ b/Firebase/Messaging/FIRMessagingPubSub.m @@ -55,7 +55,7 @@ - (instancetype)initWithClient:(FIRMessagingClient *)client { - (void)subscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(nullable NSDictionary *)options + options:(NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler { _FIRMessagingDevAssert([token length], @"FIRMessaging error no token specified"); _FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified"); @@ -98,7 +98,7 @@ - (void)subscribeWithToken:(NSString *)token - (void)unsubscribeWithToken:(NSString *)token topic:(NSString *)topic - options:(nullable NSDictionary *)options + options:(NSDictionary *)options handler:(FIRMessagingTopicOperationCompletion)handler { _FIRMessagingDevAssert([token length], @"FIRMessaging error no token specified"); _FIRMessagingDevAssert([topic length], @"FIRMessaging error Invalid empty topic specified");