Skip to content

Commit f025da1

Browse files
Remove deprecated API to connect direct channel (#2717)
1 parent 0aa81c9 commit f025da1

File tree

3 files changed

+4
-74
lines changed

3 files changed

+4
-74
lines changed

Firebase/Messaging/FIRMMessageCode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageCode) {
4646
kFIRMessagingMessageCodeAPNSTokenNotAvailableDuringTokenFetch = 2022, // I-FCM002022
4747
kFIRMessagingMessageCodeTokenDelegateMethodsNotImplemented = 2023, // I-FCM002023
4848
kFIRMessagingMessageCodeTopicFormatIsDeprecated = 2024,
49+
kFIRMessagingMessageCodeDirectChannelConnectionFailed = 2025,
4950
// FIRMessagingClient.m
5051
kFIRMessagingMessageCodeClient000 = 4000, // I-FCM004000
5152
kFIRMessagingMessageCodeClient001 = 4001, // I-FCM004001

Firebase/Messaging/FIRMessaging.m

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ - (void)updateAutomaticClientConnection {
710710
if (!error) {
711711
// It means we connected. Fire connection change notification
712712
[self notifyOfDirectChannelConnectionChange];
713+
} else {
714+
FIRMessagingLoggerError(kFIRMessagingMessageCodeDirectChannelConnectionFailed,
715+
@"Failed to connect to direct channel, error: %@\n", error);
713716
}
714717
}];
715718
} else if (!shouldBeConnected && self.client.isConnected) {
@@ -723,33 +726,6 @@ - (void)notifyOfDirectChannelConnectionChange {
723726
[center postNotificationName:FIRMessagingConnectionStateChangedNotification object:self];
724727
}
725728

726-
#pragma mark - Connect
727-
728-
- (void)connectWithCompletion:(FIRMessagingConnectCompletion)handler {
729-
_FIRMessagingDevAssert([NSThread isMainThread],
730-
@"FIRMessaging connect should be called from main thread only.");
731-
_FIRMessagingDevAssert(self.isClientSetup, @"FIRMessaging client not setup.");
732-
[self.client connectWithHandler:^(NSError *error) {
733-
if (handler) {
734-
handler(error);
735-
}
736-
if (!error) {
737-
// It means we connected. Fire connection change notification
738-
[self notifyOfDirectChannelConnectionChange];
739-
}
740-
}];
741-
742-
}
743-
744-
- (void)disconnect {
745-
_FIRMessagingDevAssert([NSThread isMainThread],
746-
@"FIRMessaging should be called from main thread only.");
747-
if ([self.client isConnected]) {
748-
[self.client disconnect];
749-
[self notifyOfDirectChannelConnectionChange];
750-
}
751-
}
752-
753729
#pragma mark - Topics
754730

755731
+ (NSString *)normalizeTopic:(NSString *)topic {

Firebase/Messaging/Public/FIRMessaging.h

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ typedef void(^FIRMessagingDeleteFCMTokenCompletion)(NSError * _Nullable error)
5757
*/
5858
typedef void (^FIRMessagingTopicOperationCompletion)(NSError *_Nullable error);
5959

60-
/**
61-
* The completion handler invoked once the data connection with FIRMessaging is
62-
* established. The data connection is used to send a continuous stream of
63-
* data and all the FIRMessaging data notifications arrive through this connection.
64-
* Once the connection is established we invoke the callback with `nil` error.
65-
* Correspondingly if we get an error while trying to establish a connection
66-
* we invoke the handler with an appropriate error object and do an
67-
* exponential backoff to try and connect again unless successful.
68-
*
69-
* @param error The error object if any describing why the data connection
70-
* to FIRMessaging failed.
71-
*/
72-
typedef void(^FIRMessagingConnectCompletion)(NSError * __nullable error)
73-
NS_SWIFT_NAME(MessagingConnectCompletion)
74-
__deprecated_msg("Please listen for the FIRMessagingConnectionStateChangedNotification "
75-
"NSNotification instead.");
76-
7760
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
7861
/**
7962
* Notification sent when the upstream message has been delivered
@@ -426,36 +409,6 @@ NS_SWIFT_NAME(Messaging)
426409
completion:(FIRMessagingDeleteFCMTokenCompletion)completion
427410
NS_SWIFT_NAME(deleteFCMToken(forSenderID:completion:));
428411

429-
430-
#pragma mark - FCM Direct Channel
431-
432-
/**
433-
* Create a FIRMessaging data connection which will be used to send the data notifications
434-
* sent by your server. It will also be used to send ACKS and other messages based
435-
* on the FIRMessaging ACKS and other messages based on the FIRMessaging protocol.
436-
*
437-
*
438-
* @param handler The handler to be invoked once the connection is established.
439-
* If the connection fails we invoke the handler with an
440-
* appropriate error code letting you know why it failed. At
441-
* the same time, FIRMessaging performs exponential backoff to retry
442-
* establishing a connection and invoke the handler when successful.
443-
*/
444-
- (void)connectWithCompletion:(FIRMessagingConnectCompletion)handler
445-
NS_SWIFT_NAME(connect(handler:))
446-
__deprecated_msg("Please use the shouldEstablishDirectChannel property instead.");
447-
448-
/**
449-
* Disconnect the current FIRMessaging data connection. This stops any attempts to
450-
* connect to FIRMessaging. Calling this on an already disconnected client is a no-op.
451-
*
452-
* Call this before `teardown` when your app is going to the background.
453-
* Since the FIRMessaging connection won't be allowed to live when in the background, it is
454-
* prudent to close the connection.
455-
*/
456-
- (void)disconnect
457-
__deprecated_msg("Please use the shouldEstablishDirectChannel property instead.");
458-
459412
#pragma mark - Topics
460413

461414
/**

0 commit comments

Comments
 (0)