Skip to content
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

Add InstanceID deprecation warning #6585

Merged
merged 6 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions Firebase/InstanceID/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2020-09 -- 4.7.0
- [changed] Added deprecation warning for InstanceID. InstanceID is deprecated, for app instance identity handling, use FirebaseInstallations. For FCM registration token handling, use FirebaseMessaging. (#6585)

# 2020-08 -- 4.6.0
- [added] Added a new notification listening token refresh from Messaging and update the token cache in InstanceID. (#6286)
- [fixed] Fixed an issue that token refresh notification is not triggered when use `tokenWithAuthorizedEntity:scope:options:handler` to get token. (#6286)
Expand Down
3 changes: 3 additions & 0 deletions Firebase/InstanceID/FIRInstanceID.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ - (id)copyWithZone:(NSZone *)zone {
}
@end

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FIRInstanceID
#pragma clang diagnostic pop

// File static to support InstanceID tests that call [FIRInstanceID instanceID] after
// [FIRInstanceID instanceIDForTests].
Expand Down
35 changes: 25 additions & 10 deletions Firebase/InstanceID/Public/FIRInstanceID.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
* The scope to be used when fetching/deleting a token for Firebase Messaging.
*/
FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging);
NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging) DEPRECATED_ATTRIBUTE;

#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
/**
Expand All @@ -37,7 +37,7 @@ FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
* to control the rate of token updates on application servers.
*/
FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotification
NS_SWIFT_NAME(InstanceIDTokenRefresh);
NS_SWIFT_NAME(InstanceIDTokenRefresh) DEPRECATED_ATTRIBUTE;
#else
/**
* Called when the system determines that tokens need to be refreshed.
Expand All @@ -48,7 +48,7 @@ FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotificatio
* to control the rate of token updates on application servers.
*/
FOUNDATION_EXPORT NSString *const kFIRInstanceIDTokenRefreshNotification
NS_SWIFT_NAME(InstanceIDTokenRefreshNotification);
NS_SWIFT_NAME(InstanceIDTokenRefreshNotification) DEPRECATED_ATTRIBUTE;
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0

/**
Expand Down Expand Up @@ -150,7 +150,10 @@ typedef NS_ENUM(NSUInteger, FIRInstanceIDError) {
* A class contains the results of InstanceID and token query.
*/
NS_SWIFT_NAME(InstanceIDResult)
@interface FIRInstanceIDResult : NSObject <NSCopying>
__deprecated_msg("FIRInstanceIDResult is deprecated, please use FIRInstallations "
"for app instance identifier handling and use FIRMessaging for "
"FCM registration token handling.") @interface FIRInstanceIDResult
: NSObject<NSCopying>

/**
* An instanceID uniquely identifies the app instance.
Expand Down Expand Up @@ -184,7 +187,9 @@ NS_SWIFT_NAME(InstanceIDResult)
* `[FIRInstanceID tokenWithAuthorizedEntity:scope:options:handler]`.
*/
NS_SWIFT_NAME(InstanceID)
@interface FIRInstanceID : NSObject
__deprecated_msg("FIRInstanceID is deprecated, please use FIRInstallations for installation "
"identifier handling and use FIRMessaging for FCM registration token handling.")
@interface FIRInstanceID : NSObject

/**
* FIRInstanceID.
Expand All @@ -206,7 +211,10 @@ NS_SWIFT_NAME(InstanceID)
* are generated and returned. If instanceID and token fetching fail for some
* reason the callback is invoked with nil `result` and the appropriate error.
*/
- (void)instanceIDWithHandler:(FIRInstanceIDResultHandler)handler;
- (void)instanceIDWithHandler:(FIRInstanceIDResultHandler)handler
__deprecated_msg("Use `Installations.installationID(completion:)` to get the app instance "
"identifier instead. "
"Use `Messaging.token(completion:)` to get FCM registration token instead.");

/**
* Returns a token that authorizes an Entity (example: cloud service) to perform
Expand Down Expand Up @@ -250,7 +258,8 @@ NS_SWIFT_NAME(InstanceID)
- (void)tokenWithAuthorizedEntity:(NSString *)authorizedEntity
scope:(NSString *)scope
options:(nullable NSDictionary *)options
handler:(FIRInstanceIDTokenHandler)handler;
handler:(FIRInstanceIDTokenHandler)handler
__deprecated_msg("Use Messaging.token(completion:) instead.");

/**
* Revokes access to a scope (action) for an entity previously
Expand All @@ -273,7 +282,8 @@ NS_SWIFT_NAME(InstanceID)
*/
- (void)deleteTokenWithAuthorizedEntity:(NSString *)authorizedEntity
scope:(NSString *)scope
handler:(FIRInstanceIDDeleteTokenHandler)handler;
handler:(FIRInstanceIDDeleteTokenHandler)handler
__deprecated_msg("Use `Messaging.deleteToken(completion:)` instead.");

#pragma mark - Identity

Expand All @@ -291,7 +301,9 @@ NS_SWIFT_NAME(InstanceID)
* a valid identifier is returned and a valid identifier for the
* application instance.
*/
- (void)getIDWithHandler:(FIRInstanceIDHandler)handler NS_SWIFT_NAME(getID(handler:));
- (void)getIDWithHandler:(FIRInstanceIDHandler)handler
NS_SWIFT_NAME(getID(handler:))
__deprecated_msg("Use `Installations.installationID(completion:)` instead.");

/**
* Resets Instance ID and revokes all tokens.
Expand All @@ -305,7 +317,10 @@ NS_SWIFT_NAME(InstanceID)
* (like FCM, RemoteConfig or Analytics) or user explicitly calls Instance ID APIs to get an
* Instance ID and token again.
*/
- (void)deleteIDWithHandler:(FIRInstanceIDDeleteHandler)handler NS_SWIFT_NAME(deleteID(handler:));
- (void)deleteIDWithHandler:(FIRInstanceIDDeleteHandler)handler NS_SWIFT_NAME(deleteID(handler:))
__deprecated_msg("Use `Installations.delete(completion:)` instead. "
"Also check `Messaging.deleteData(completion:)`"
"if you want to delete FCM registration token.");

@end

Expand Down
2 changes: 1 addition & 1 deletion FirebaseInstanceID.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseInstanceID'
s.version = '4.7.0'
s.version = '4.8.0'
s.summary = 'Firebase InstanceID'

s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion FirebaseMessaging.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FirebaseMessaging'
s.version = '4.7.0'
s.version = '4.7.1'
s.summary = 'Firebase Messaging'

s.description = <<-DESC
Expand Down
3 changes: 3 additions & 0 deletions FirebaseMessaging/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2020-09 -- v.4.7.1
- [added] InstanceID is deprecated, add macro to supress deprecation warning. (#6585)

# 2020-09 -- v.4.7.0
- [added] Added new token APIs to get and delete the default FCM registration token asynchronously. Also added a new `Messaging.delete(completion:)` method that deletes all FCM registration tokens and checkin data. (#6313)

Expand Down
3 changes: 3 additions & 0 deletions FirebaseMessaging/Sources/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ + (void)load {
// Ensure it's cached so it returns the same instance every time messaging is called.
*isCacheable = YES;
id<FIRAnalyticsInterop> analytics = FIR_COMPONENT(FIRAnalyticsInterop, container);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRMessaging *messaging =
[[FIRMessaging alloc] initWithAnalytics:analytics
withInstanceID:[FIRInstanceID instanceID]
withUserDefaults:[GULUserDefaults standardUserDefaults]];
#pragma clang diagnostic pop
[messaging start];
[messaging configureNotificationSwizzlingIfEnabled];
return messaging;
Expand Down
13 changes: 12 additions & 1 deletion FirebaseMessaging/Sources/FIRMessagingClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ - (void)connect {
}

self.stayConnected = YES;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (![[FIRInstanceID instanceID] tryToLoadValidCheckinInfo]) {
#pragma clang diagnostic pop
// Checkin info is not available. This may be due to the checkin still being fetched.
NSString *failureReason = @"Failed to connect to MCS. No deviceID and secret found.";
if (self.connectHandler) {
Expand Down Expand Up @@ -319,9 +322,11 @@ - (void)didLoginWithConnection:(FIRMessagingConnection *)fcmConnection {
object:nil];
self.connectRetryCount = 0;
self.lastConnectedTimestamp = FIRMessagingCurrentTimestampInMilliseconds();

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self.dataMessageManager setDeviceAuthID:[FIRInstanceID instanceID].deviceAuthID
secretToken:[FIRInstanceID instanceID].secretToken];
#pragma clang diagnostic pop
if (self.connectHandler) {
self.connectHandler(nil);
// notified the third party app with the registrationId.
Expand Down Expand Up @@ -371,6 +376,8 @@ - (void)setupConnection {
[self.connection signOut];
self.connection.delegate = nil;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.connection =
[[FIRMessagingConnection alloc] initWithAuthID:[FIRInstanceID instanceID].deviceAuthID
token:[FIRInstanceID instanceID].secretToken
Expand All @@ -379,6 +386,7 @@ - (void)setupConnection {
runLoop:[NSRunLoop mainRunLoop]
rmq2Manager:self.rmq2Manager
fcmManager:self.dataMessageManager];
#pragma clang diagnostic pop
self.connection.delegate = self;
}

Expand All @@ -391,8 +399,11 @@ - (void)tryToConnect {
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(tryToConnect)
object:nil];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSString *deviceAuthID = [FIRInstanceID instanceID].deviceAuthID;
NSString *secretToken = [FIRInstanceID instanceID].secretToken;
#pragma clang diagnostic pop
if (deviceAuthID.length == 0 || secretToken.length == 0 || !self.connection) {
FIRMessagingLoggerWarn(
kFIRMessagingMessageCodeClientInvalidState,
Expand Down
3 changes: 3 additions & 0 deletions FirebaseMessaging/Sources/FIRMessagingPubSub.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ - (void)updateSubscriptionWithToken:(NSString *)token
options:(NSDictionary *)options
shouldDelete:(BOOL)shouldDelete
handler:(FIRMessagingTopicOperationCompletion)handler {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([[FIRInstanceID instanceID] tryToLoadValidCheckinInfo]) {
#pragma clang diagnostic pop
FIRMessagingTopicAction action =
shouldDelete ? FIRMessagingTopicActionUnsubscribe : FIRMessagingTopicActionSubscribe;
FIRMessagingTopicOperation *operation = [[FIRMessagingTopicOperation alloc]
Expand Down
4 changes: 3 additions & 1 deletion FirebaseMessaging/Sources/FIRMessagingTopicOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ - (void)performSubscriptionChange {
NSURL *url = [NSURL URLWithString:FIRMessagingSubscriptionsServer()];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *appIdentifier = FIRMessagingAppIdentifier();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSString *deviceAuthID = [FIRInstanceID instanceID].deviceAuthID;
NSString *secretToken = [FIRInstanceID instanceID].secretToken;
NSString *authString = [NSString stringWithFormat:@"AidLogin %@:%@", deviceAuthID, secretToken];
[request setValue:authString forHTTPHeaderField:@"Authorization"];
[request setValue:appIdentifier forHTTPHeaderField:@"app"];
[request setValue:[FIRInstanceID instanceID].versionInfo forHTTPHeaderField:@"info"];

#pragma clang diagnostic pop
// Topic can contain special characters (like `%`) so encode the value.
NSCharacterSet *characterSet = [NSCharacterSet URLQueryAllowedCharacterSet];
NSString *encodedTopic =
Expand Down