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 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

static BOOL sFIRInstanceIDFirebaseDefaultAppConfigured = NO;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface FIRInstanceIDIntegrationTests : XCTestCase
@property(nonatomic, strong) FIRInstanceID *instanceID;
@end
Expand Down Expand Up @@ -134,6 +136,7 @@ - (void)assertTokenWithAuthorizedEntity {

[self waitForExpectations:@[ expectation ] timeout:5];
}
#pragma clang diagnostic pop

- (NSString *)tokenAuthorizedEntity {
if (!sFIRInstanceIDFirebaseDefaultAppConfigured) {
Expand Down
10 changes: 10 additions & 0 deletions Example/InstanceID/Tests/FIRInstanceIDResultTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ - (void)start;
@end

@interface FIRInstanceIDResultTest : XCTestCase {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
FIRInstanceID *_instanceID;
#pragma clang diagnostic pop

id _mockInstanceID;
}

Expand All @@ -45,7 +49,10 @@ @implementation FIRInstanceIDResultTest

- (void)setUp {
[super setUp];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_mockInstanceID = OCMClassMock([FIRInstanceID class]);
#pragma clang diagnostic pop
}

- (void)tearDown {
Expand All @@ -54,6 +61,8 @@ - (void)tearDown {
[super tearDown];
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)testResultWithFailedIID {
// mocking getting iid failed with error.
OCMStub([_mockInstanceID
Expand Down Expand Up @@ -130,5 +139,6 @@ - (void)testResultCanBeCoplied {
XCTAssertEqualObjects(resultCopy.token, kFakeToken);
}];
}
#pragma clang diagnostic pop

@end
16 changes: 13 additions & 3 deletions Example/InstanceID/Tests/FIRInstanceIDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ - (void)fetchNewTokenWithAuthorizedEntity:(NSString *)authorizedEntity
@interface FIRInstanceIDTest : XCTestCase

@property(nonatomic, readwrite, assign) BOOL hasCheckinInfo;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property(nonatomic, readwrite, strong) FIRInstanceID *instanceID;
#pragma clang diagnostic pop
@property(nonatomic, readwrite, strong) id mockInstanceID;
@property(nonatomic, readwrite, strong) id mockTokenManager;
@property(nonatomic, readwrite, strong) id mockInstallations;
Expand All @@ -89,6 +92,8 @@ @interface FIRInstanceIDTest : XCTestCase

@implementation FIRInstanceIDTest

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)setUp {
[super setUp];

Expand Down Expand Up @@ -134,8 +139,11 @@ - (void)mockInstanceIDObjects {
_instanceID.fcmSenderID = kAuthorizedEntity;
self.mockInstanceID = OCMPartialMock(_instanceID);
[self.mockInstanceID setTokenManager:self.mockTokenManager];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
id instanceIDClassMock = OCMClassMock([FIRInstanceID class]);
#pragma clang diagnostic pop

OCMStub(ClassMethod([instanceIDClassMock minIntervalForDefaultTokenRetry])).andReturn(2);
OCMStub(ClassMethod([instanceIDClassMock maxRetryIntervalForDefaultTokenInSeconds]))
.andReturn(10);
Expand All @@ -146,6 +154,8 @@ - (void)mockInstanceIDObjects {
* FIRInstanceID with an associated FIRInstanceIDTokenManager.
*/
- (void)testSharedInstance {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// The shared instance should be `nil` before the app is configured.
XCTAssertNil([FIRInstanceID instanceID]);

Expand All @@ -168,8 +178,7 @@ - (void)testSharedInstance {

// Verify FirebaseInstallations requested for FID.
OCMVerifyAll(self.mockInstallations);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

XCTAssertEqualObjects([instanceID appInstanceID:NULL], @"fid");
#pragma clang diagnostic pop

Expand Down Expand Up @@ -1470,5 +1479,6 @@ - (id)errorCompletionOCMArgCompletingWithError:(NSError *)errorToComplete {
return YES;
}];
}
#pragma clang diagnostic pop

@end
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+Private.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ @interface FIRInstanceID ()

@end

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

// This method just wraps our pre-configured auth service to make the request.
// This method is only needed by first-party users, like Remote Config.
Expand Down
6 changes: 6 additions & 0 deletions Firebase/InstanceID/FIRInstanceID.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ @protocol FIRInstanceIDInstanceProvider
@interface FIRInstanceID () <FIRInstanceIDInstanceProvider, FIRLibrary>
@end

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation FIRInstanceIDResult
#pragma clang diagnostic pop
- (id)copyWithZone:(NSZone *)zone {
FIRInstanceIDResult *result = [[[self class] allocWithZone:zone] init];
result.instanceID = self.instanceID;
Expand All @@ -141,7 +144,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
3 changes: 3 additions & 0 deletions Firebase/InstanceID/FIRInstanceIDUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ BOOL FIRInstanceIDHasLocaleChanged() {
#pragma mark - Helpers

BOOL FIRInstanceIDIsValidGCMScope(NSString *scope) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [scope compare:kFIRInstanceIDScopeFirebaseMessaging
options:NSCaseInsensitiveSearch] == NSOrderedSame;
#pragma clang diagnostic pop
}

NSString *FIRInstanceIDStringForAPNSDeviceToken(NSData *deviceToken) {
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 suppress 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
Loading