Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Firebase/Messaging/FIRMMessageCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) {
kFIRMessagingMessageCodeAPNSTokenNotAvailableDuringTokenFetch = 2022, // I-FCM002022
kFIRMessagingMessageCodeTokenDelegateMethodsNotImplemented = 2023, // I-FCM002023
kFIRMessagingMessageCodeTopicFormatIsDeprecated = 2024,
kFIRMessagingMessageCodeDirectChannelConnectionFailed = 2025,
// FIRMessagingClient.m
kFIRMessagingMessageCodeClient000 = 4000, // I-FCM004000
kFIRMessagingMessageCodeClient001 = 4001, // I-FCM004001
Expand Down
30 changes: 3 additions & 27 deletions Firebase/Messaging/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ - (void)updateAutomaticClientConnection {
if (!error) {
// It means we connected. Fire connection change notification
[self notifyOfDirectChannelConnectionChange];
} else {
FIRMessagingLoggerError(kFIRMessagingMessageCodeDirectChannelConnectionFailed,
@"Failed to connect to direct channel, error: %@\n", error);
}
}];
} else if (!shouldBeConnected && self.client.isConnected) {
Expand All @@ -732,33 +735,6 @@ - (void)notifyOfDirectChannelConnectionChange {
[center postNotificationName:FIRMessagingConnectionStateChangedNotification object:self];
}

#pragma mark - Connect

- (void)connectWithCompletion:(FIRMessagingConnectCompletion)handler {
_FIRMessagingDevAssert([NSThread isMainThread],
@"FIRMessaging connect should be called from main thread only.");
_FIRMessagingDevAssert(self.isClientSetup, @"FIRMessaging client not setup.");
[self.client connectWithHandler:^(NSError *error) {
if (handler) {
handler(error);
}
if (!error) {
// It means we connected. Fire connection change notification
[self notifyOfDirectChannelConnectionChange];
}
}];

}

- (void)disconnect {
_FIRMessagingDevAssert([NSThread isMainThread],
@"FIRMessaging should be called from main thread only.");
if ([self.client isConnected]) {
[self.client disconnect];
[self notifyOfDirectChannelConnectionChange];
}
}

#pragma mark - Topics

+ (NSString *)normalizeTopic:(NSString *)topic {
Expand Down
47 changes: 0 additions & 47 deletions Firebase/Messaging/Public/FIRMessaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,6 @@ typedef void(^FIRMessagingDeleteFCMTokenCompletion)(NSError * _Nullable error)
*/
typedef void (^FIRMessagingTopicOperationCompletion)(NSError *_Nullable error);

/**
* The completion handler invoked once the data connection with FIRMessaging is
* established. The data connection is used to send a continuous stream of
* data and all the FIRMessaging data notifications arrive through this connection.
* Once the connection is established we invoke the callback with `nil` error.
* Correspondingly if we get an error while trying to establish a connection
* we invoke the handler with an appropriate error object and do an
* exponential backoff to try and connect again unless successful.
*
* @param error The error object if any describing why the data connection
* to FIRMessaging failed.
*/
typedef void(^FIRMessagingConnectCompletion)(NSError * __nullable error)
NS_SWIFT_NAME(MessagingConnectCompletion)
__deprecated_msg("Please listen for the FIRMessagingConnectionStateChangedNotification "
"NSNotification instead.");

#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
* Notification sent when the upstream message has been delivered
Expand Down Expand Up @@ -448,36 +431,6 @@ NS_SWIFT_NAME(Messaging)
completion:(FIRMessagingDeleteFCMTokenCompletion)completion
NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:));


#pragma mark - FCM Direct Channel

/**
* Create a FIRMessaging data connection which will be used to send the data notifications
* sent by your server. It will also be used to send ACKS and other messages based
* on the FIRMessaging ACKS and other messages based on the FIRMessaging protocol.
*
*
* @param handler The handler to be invoked once the connection is established.
* If the connection fails we invoke the handler with an
* appropriate error code letting you know why it failed. At
* the same time, FIRMessaging performs exponential backoff to retry
* establishing a connection and invoke the handler when successful.
*/
- (void)connectWithCompletion:(FIRMessagingConnectCompletion)handler
NS_SWIFT_NAME(connect(handler:))
__deprecated_msg("Please use the shouldEstablishDirectChannel property instead.");

/**
* Disconnect the current FIRMessaging data connection. This stops any attempts to
* connect to FIRMessaging. Calling this on an already disconnected client is a no-op.
*
* Call this before `teardown` when your app is going to the background.
* Since the FIRMessaging connection won't be allowed to live when in the background, it is
* prudent to close the connection.
*/
- (void)disconnect
__deprecated_msg("Please use the shouldEstablishDirectChannel property instead.");

#pragma mark - Topics

/**
Expand Down