Skip to content

Remove deprecated token callback #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 12, 2018
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
17 changes: 4 additions & 13 deletions Firebase/Messaging/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -572,18 +572,16 @@ - (void)setDelegate:(id<FIRMessagingDelegate>)delegate {
[self validateDelegateConformsToTokenAvailabilityMethods];
}

// Check if the delegate conforms to either |didReceiveRegistrationToken:| or
// |didRefreshRegistrationToken:|, and display a warning to the developer if not.
// Check if the delegate conforms to |didReceiveRegistrationToken:|
// and display a warning to the developer if not.
// NOTE: Once |didReceiveRegistrationToken:| can be made a required method, this
// check can be removed.
- (void)validateDelegateConformsToTokenAvailabilityMethods {
if (self.delegate &&
![self.delegate respondsToSelector:@selector(messaging:didReceiveRegistrationToken:)] &&
![self.delegate respondsToSelector:@selector(messaging:didRefreshRegistrationToken:)]) {
![self.delegate respondsToSelector:@selector(messaging:didReceiveRegistrationToken:)]) {
FIRMessagingLoggerWarn(kFIRMessagingMessageCodeTokenDelegateMethodsNotImplemented,
@"The object %@ does not respond to "
@"-messaging:didReceiveRegistrationToken:, nor "
@"-messaging:didRefreshRegistrationToken:. Please implement "
@"-messaging:didReceiveRegistrationToken:. Please implement "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: While we're making this change, we should change to the Swift signature to match (almost) all of our other logs and documentation: messaging(_:didReceiveRegistrationToken:).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I will notify the doc team on the change during launch.

I believe all the public doc is using the recommended API (objc & swift), also I've checked all source code the deprecated methods have been removed. Let me know if there's anything you think might be missing.

@"-messaging:didReceiveRegistrationToken: to be provided with an FCM "
@"token.", self.delegate.description);
}
Expand Down Expand Up @@ -877,13 +875,6 @@ - (void)defaultInstanceIDTokenWasRefreshed:(NSNotification *)notification {
if (self.defaultFcmToken && ![self.defaultFcmToken isEqualToString:oldToken]) {
[self notifyDelegateOfFCMTokenAvailability];
}
// Call deprecated refresh method, because it should still work (until it is removed).
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([self.delegate respondsToSelector:@selector(messaging:didRefreshRegistrationToken:)]) {
[self.delegate messaging:self didRefreshRegistrationToken:token];
}
#pragma clang diagnostic pop
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center postNotificationName:FIRMessagingRegistrationTokenRefreshedNotification object:nil];
}
Expand Down
13 changes: 1 addition & 12 deletions Firebase/Messaging/Public/FIRMessaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,8 @@ NS_SWIFT_NAME(MessagingRemoteMessage)

@class FIRMessaging;
/**
* A protocol to handle events from FCM for devices running iOS 10 or above.
* A protocol to handle token update or data message delivery from FCM.
*
* To support devices running iOS 9 or below, use the local and remote notifications handlers
* defined in UIApplicationDelegate protocol.
*/
NS_SWIFT_NAME(MessagingDelegate)
@protocol FIRMessagingDelegate <NSObject>
Expand All @@ -259,15 +257,6 @@ NS_SWIFT_NAME(MessagingDelegate)
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:(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.
Expand Down