Skip to content

Commit

Permalink
Merge pull request firebase#1035 from morganchen12/firmessaging-nonnull
Browse files Browse the repository at this point in the history
add NS_ASSUME_NONNULL macros to messaging
  • Loading branch information
morganchen12 authored Apr 5, 2018
2 parents b000c63 + c4b1aef commit 8d3d908
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 34 deletions.
4 changes: 4 additions & 0 deletions Firebase/Messaging/FIRMessagingPubSub.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import "FIRMessaging.h"

NS_ASSUME_NONNULL_BEGIN

@class FIRMessagingClient;
@class FIRMessagingPubSubCache;

Expand Down Expand Up @@ -155,3 +157,5 @@
+ (BOOL)isValidTopicWithPrefix:(NSString *)topic;

@end

NS_ASSUME_NONNULL_END
72 changes: 38 additions & 34 deletions Firebase/Messaging/Public/FIRMessaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* @related FIRMessaging
*
Expand Down Expand Up @@ -78,7 +80,7 @@ typedef void(^FIRMessagingConnectCompletion)(NSError * __nullable error)
* successfully to the server. The notification object will be the messageID
* of the successfully delivered message.
*/
FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendSuccessNotification
FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendSuccessNotification
NS_SWIFT_NAME(MessagingSendSuccess);

/**
Expand All @@ -87,7 +89,7 @@ FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendSuccessNoti
* message. The userInfo dictionary will contain the relevant error
* information for the failure.
*/
FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendErrorNotification
FOUNDATION_EXPORT const NSNotificationName FIRMessagingSendErrorNotification
NS_SWIFT_NAME(MessagingSendError);

/**
Expand All @@ -98,23 +100,23 @@ FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingSendErrorNotifi
* It is recommended to retrieve any missing messages directly from the
* server.
*/
FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingMessagesDeletedNotification
FOUNDATION_EXPORT const NSNotificationName FIRMessagingMessagesDeletedNotification
NS_SWIFT_NAME(MessagingMessagesDeleted);

/**
* Notification sent when Firebase Messaging establishes or disconnects from
* an FCM socket connection. You can query the connection state in this
* notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
*/
FOUNDATION_EXPORT const NSNotificationName __nonnull FIRMessagingConnectionStateChangedNotification
FOUNDATION_EXPORT const NSNotificationName FIRMessagingConnectionStateChangedNotification
NS_SWIFT_NAME(MessagingConnectionStateChanged);

/**
* Notification sent when the FCM registration token has been refreshed. Please use the
* FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
* updated tokens.
*/
FOUNDATION_EXPORT const NSNotificationName __nonnull
FOUNDATION_EXPORT const NSNotificationName
FIRMessagingRegistrationTokenRefreshedNotification
NS_SWIFT_NAME(MessagingRegistrationTokenRefreshed);
#else
Expand All @@ -123,7 +125,7 @@ FOUNDATION_EXPORT const NSNotificationName __nonnull
* successfully to the server. The notification object will be the messageID
* of the successfully delivered message.
*/
FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendSuccessNotification
FOUNDATION_EXPORT NSString *const FIRMessagingSendSuccessNotification
NS_SWIFT_NAME(MessagingSendSuccessNotification);

/**
Expand All @@ -132,7 +134,7 @@ FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendSuccessNotification
* message. The userInfo dictionary will contain the relevant error
* information for the failure.
*/
FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendErrorNotification
FOUNDATION_EXPORT NSString *const FIRMessagingSendErrorNotification
NS_SWIFT_NAME(MessagingSendErrorNotification);

/**
Expand All @@ -143,23 +145,23 @@ FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingSendErrorNotification
* It is recommended to retrieve any missing messages directly from the
* server.
*/
FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingMessagesDeletedNotification
FOUNDATION_EXPORT NSString *const FIRMessagingMessagesDeletedNotification
NS_SWIFT_NAME(MessagingMessagesDeletedNotification);

/**
* Notification sent when Firebase Messaging establishes or disconnects from
* an FCM socket connection. You can query the connection state in this
* notification by checking the `isDirectChannelEstablished` property of FIRMessaging.
*/
FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingConnectionStateChangedNotification
FOUNDATION_EXPORT NSString *const FIRMessagingConnectionStateChangedNotification
NS_SWIFT_NAME(MessagingConnectionStateChangedNotification);

/**
* Notification sent when the FCM registration token has been refreshed. Please use the
* FIRMessaging delegate method `messaging:didReceiveRegistrationToken:` to receive current and
* updated tokens.
*/
FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingRegistrationTokenRefreshedNotification
FOUNDATION_EXPORT NSString *const FIRMessagingRegistrationTokenRefreshedNotification
NS_SWIFT_NAME(MessagingRegistrationTokenRefreshedNotification);
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0

Expand Down Expand Up @@ -232,7 +234,7 @@ NS_SWIFT_NAME(MessagingRemoteMessage)
@interface FIRMessagingRemoteMessage : NSObject

/// The downstream message received by the application.
@property(nonatomic, readonly, strong, nonnull) NSDictionary *appData;
@property(nonatomic, readonly, strong) NSDictionary *appData;
@end

@class FIRMessaging;
Expand All @@ -253,29 +255,29 @@ NS_SWIFT_NAME(MessagingDelegate)
/// * Uploading the FCM token to your application server, so targeted notifications can be sent.
///
/// * Subscribing to any topics.
- (void)messaging:(nonnull FIRMessaging *)messaging
didReceiveRegistrationToken:(nonnull NSString *)fcmToken
- (void)messaging:(FIRMessaging *)messaging
didReceiveRegistrationToken:(NSString *)fcmToken
NS_SWIFT_NAME(messaging(_:didReceiveRegistrationToken:));

/// This method will be called whenever FCM receives a new, default FCM token for your
/// Firebase project's Sender ID. This method is deprecated. Please use
/// `messaging:didReceiveRegistrationToken:`.
- (void)messaging:(nonnull FIRMessaging *)messaging
didRefreshRegistrationToken:(nonnull NSString *)fcmToken
- (void)messaging:(FIRMessaging *)messaging
didRefreshRegistrationToken:(NSString *)fcmToken
NS_SWIFT_NAME(messaging(_:didRefreshRegistrationToken:))
__deprecated_msg("Please use messaging:didReceiveRegistrationToken:, which is called for both \
current and refreshed tokens.");

/// This method is called on iOS 10 devices to handle data messages received via FCM through its
/// direct channel (not via APNS). For iOS 9 and below, the FCM data message is delivered via the
/// UIApplicationDelegate's -application:didReceiveRemoteNotification: method.
- (void)messaging:(nonnull FIRMessaging *)messaging
didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage
- (void)messaging:(FIRMessaging *)messaging
didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage
NS_SWIFT_NAME(messaging(_:didReceive:))
__IOS_AVAILABLE(10.0);

/// The callback to handle data message received via FCM for devices running iOS 10 or above.
- (void)applicationReceivedRemoteMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage
- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage
NS_SWIFT_NAME(application(received:))
__deprecated_msg("Use FIRMessagingDelegate’s -messaging:didReceiveMessage:");

Expand Down Expand Up @@ -323,12 +325,12 @@ NS_SWIFT_NAME(Messaging)
*
* @return An instance of FIRMessaging.
*/
+ (nonnull instancetype)messaging NS_SWIFT_NAME(messaging());
+ (instancetype)messaging NS_SWIFT_NAME(messaging());

/**
* Unavailable. Use +messaging instead.
*/
- (nonnull instancetype)init __attribute__((unavailable("Use +messaging instead.")));
- (instancetype)init __attribute__((unavailable("Use +messaging instead.")));

#pragma mark - APNS

Expand Down Expand Up @@ -358,7 +360,7 @@ NS_SWIFT_NAME(Messaging)
* FIRMessagingAPNSTokenTypeUnknown to have the type automatically
* detected based on your provisioning profile.
*/
- (void)setAPNSToken:(nonnull NSData *)apnsToken type:(FIRMessagingAPNSTokenType)type;
- (void)setAPNSToken:(NSData *)apnsToken type:(FIRMessagingAPNSTokenType)type;

#pragma mark - FCM Tokens

Expand Down Expand Up @@ -413,8 +415,8 @@ NS_SWIFT_NAME(Messaging)
* @param senderID The Sender ID for a particular Firebase project.
* @param completion The completion handler to handle the token request.
*/
- (void)retrieveFCMTokenForSenderID:(nonnull NSString *)senderID
completion:(nonnull FIRMessagingFCMTokenFetchCompletion)completion
- (void)retrieveFCMTokenForSenderID:(NSString *)senderID
completion:(FIRMessagingFCMTokenFetchCompletion)completion
NS_SWIFT_NAME(retrieveFCMToken(forSenderID:completion:));


Expand All @@ -425,8 +427,8 @@ NS_SWIFT_NAME(Messaging)
* @param senderID The senderID for a particular Firebase project.
* @param completion The completion handler to handle the token deletion.
*/
- (void)deleteFCMTokenForSenderID:(nonnull NSString *)senderID
completion:(nonnull FIRMessagingDeleteFCMTokenCompletion)completion
- (void)deleteFCMTokenForSenderID:(NSString *)senderID
completion:(FIRMessagingDeleteFCMTokenCompletion)completion
NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:));


Expand All @@ -444,7 +446,7 @@ NS_SWIFT_NAME(Messaging)
* the same time, FIRMessaging performs exponential backoff to retry
* establishing a connection and invoke the handler when successful.
*/
- (void)connectWithCompletion:(nonnull FIRMessagingConnectCompletion)handler
- (void)connectWithCompletion:(FIRMessagingConnectCompletion)handler
NS_SWIFT_NAME(connect(handler:))
__deprecated_msg("Please use the shouldEstablishDirectChannel property instead.");

Expand All @@ -466,7 +468,7 @@ NS_SWIFT_NAME(Messaging)
*
* @param topic The name of the topic, for example, @"sports".
*/
- (void)subscribeToTopic:(nonnull NSString *)topic NS_SWIFT_NAME(subscribe(toTopic:));
- (void)subscribeToTopic:(NSString *)topic NS_SWIFT_NAME(subscribe(toTopic:));

/**
* Asynchronously subscribe to the provided topic, retrying on failure.
Expand All @@ -476,15 +478,15 @@ NS_SWIFT_NAME(Messaging)
* In case of success, nil error is returned. Otherwise, an
* appropriate error object is returned.
*/
- (void)subscribeToTopic:(nonnull NSString *)topic
- (void)subscribeToTopic:(NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion;

/**
* Asynchronously unsubscribe from a topic.
*
* @param topic The name of the topic, for example @"sports".
*/
- (void)unsubscribeFromTopic:(nonnull NSString *)topic NS_SWIFT_NAME(unsubscribe(fromTopic:));
- (void)unsubscribeFromTopic:(NSString *)topic NS_SWIFT_NAME(unsubscribe(fromTopic:));

/**
* Asynchronously unsubscribe from the provided topic, retrying on failure.
Expand All @@ -494,7 +496,7 @@ NS_SWIFT_NAME(Messaging)
* In case of success, nil error is returned. Otherwise, an
* appropriate error object is returned.
*/
- (void)unsubscribeFromTopic:(nonnull NSString *)topic
- (void)unsubscribeFromTopic:(NSString *)topic
completion:(nullable FIRMessagingTopicOperationCompletion)completion;

#pragma mark - Upstream
Expand Down Expand Up @@ -522,9 +524,9 @@ NS_SWIFT_NAME(Messaging)
* if the message has been dropped because of TTL; this can happen
* on the server side, and it would require extra communication.
*/
- (void)sendMessage:(nonnull NSDictionary *)message
to:(nonnull NSString *)receiver
withMessageID:(nonnull NSString *)messageID
- (void)sendMessage:(NSDictionary *)message
to:(NSString *)receiver
withMessageID:(NSString *)messageID
timeToLive:(int64_t)ttl;

#pragma mark - Analytics
Expand All @@ -540,6 +542,8 @@ NS_SWIFT_NAME(Messaging)
*
* @return Information about the downstream message.
*/
- (nonnull FIRMessagingMessageInfo *)appDidReceiveMessage:(nonnull NSDictionary *)message;
- (FIRMessagingMessageInfo *)appDidReceiveMessage:(NSDictionary *)message;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 8d3d908

Please sign in to comment.