Skip to content

Commit f0e7b8e

Browse files
Add InstanceID deprecation warning (#6585)
1 parent a039948 commit f0e7b8e

23 files changed

+144
-30
lines changed

Example/InstanceID/IntegrationTests/FIRInstanceIDIntegrationTests.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
static BOOL sFIRInstanceIDFirebaseDefaultAppConfigured = NO;
2828

29+
#pragma clang diagnostic push
30+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
2931
@interface FIRInstanceIDIntegrationTests : XCTestCase
3032
@property(nonatomic, strong) FIRInstanceID *instanceID;
3133
@end
@@ -134,6 +136,7 @@ - (void)assertTokenWithAuthorizedEntity {
134136

135137
[self waitForExpectations:@[ expectation ] timeout:5];
136138
}
139+
#pragma clang diagnostic pop
137140

138141
- (NSString *)tokenAuthorizedEntity {
139142
if (!sFIRInstanceIDFirebaseDefaultAppConfigured) {

Example/InstanceID/Tests/FIRInstanceIDResultTest.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ - (void)start;
3535
@end
3636

3737
@interface FIRInstanceIDResultTest : XCTestCase {
38+
#pragma clang diagnostic push
39+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
3840
FIRInstanceID *_instanceID;
41+
#pragma clang diagnostic pop
42+
3943
id _mockInstanceID;
4044
}
4145

@@ -45,7 +49,10 @@ @implementation FIRInstanceIDResultTest
4549

4650
- (void)setUp {
4751
[super setUp];
52+
#pragma clang diagnostic push
53+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
4854
_mockInstanceID = OCMClassMock([FIRInstanceID class]);
55+
#pragma clang diagnostic pop
4956
}
5057

5158
- (void)tearDown {
@@ -54,6 +61,8 @@ - (void)tearDown {
5461
[super tearDown];
5562
}
5663

64+
#pragma clang diagnostic push
65+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
5766
- (void)testResultWithFailedIID {
5867
// mocking getting iid failed with error.
5968
OCMStub([_mockInstanceID
@@ -130,5 +139,6 @@ - (void)testResultCanBeCoplied {
130139
XCTAssertEqualObjects(resultCopy.token, kFakeToken);
131140
}];
132141
}
142+
#pragma clang diagnostic pop
133143

134144
@end

Example/InstanceID/Tests/FIRInstanceIDTest.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ - (void)fetchNewTokenWithAuthorizedEntity:(NSString *)authorizedEntity
7575
@interface FIRInstanceIDTest : XCTestCase
7676

7777
@property(nonatomic, readwrite, assign) BOOL hasCheckinInfo;
78+
#pragma clang diagnostic push
79+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
7880
@property(nonatomic, readwrite, strong) FIRInstanceID *instanceID;
81+
#pragma clang diagnostic pop
7982
@property(nonatomic, readwrite, strong) id mockInstanceID;
8083
@property(nonatomic, readwrite, strong) id mockTokenManager;
8184
@property(nonatomic, readwrite, strong) id mockInstallations;
@@ -89,6 +92,8 @@ @interface FIRInstanceIDTest : XCTestCase
8992

9093
@implementation FIRInstanceIDTest
9194

95+
#pragma clang diagnostic push
96+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
9297
- (void)setUp {
9398
[super setUp];
9499

@@ -134,8 +139,11 @@ - (void)mockInstanceIDObjects {
134139
_instanceID.fcmSenderID = kAuthorizedEntity;
135140
self.mockInstanceID = OCMPartialMock(_instanceID);
136141
[self.mockInstanceID setTokenManager:self.mockTokenManager];
137-
142+
#pragma clang diagnostic push
143+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
138144
id instanceIDClassMock = OCMClassMock([FIRInstanceID class]);
145+
#pragma clang diagnostic pop
146+
139147
OCMStub(ClassMethod([instanceIDClassMock minIntervalForDefaultTokenRetry])).andReturn(2);
140148
OCMStub(ClassMethod([instanceIDClassMock maxRetryIntervalForDefaultTokenInSeconds]))
141149
.andReturn(10);
@@ -146,6 +154,8 @@ - (void)mockInstanceIDObjects {
146154
* FIRInstanceID with an associated FIRInstanceIDTokenManager.
147155
*/
148156
- (void)testSharedInstance {
157+
#pragma clang diagnostic push
158+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
149159
// The shared instance should be `nil` before the app is configured.
150160
XCTAssertNil([FIRInstanceID instanceID]);
151161

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

169179
// Verify FirebaseInstallations requested for FID.
170180
OCMVerifyAll(self.mockInstallations);
171-
#pragma clang diagnostic push
172-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
181+
173182
XCTAssertEqualObjects([instanceID appInstanceID:NULL], @"fid");
174183
#pragma clang diagnostic pop
175184

@@ -1470,5 +1479,6 @@ - (id)errorCompletionOCMArgCompletingWithError:(NSError *)errorToComplete {
14701479
return YES;
14711480
}];
14721481
}
1482+
#pragma clang diagnostic pop
14731483

14741484
@end

Firebase/InstanceID/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2020-09 -- 4.7.0
2+
- [changed] Added deprecation warning for InstanceID. InstanceID is deprecated. For app instance identity handling, use FirebaseInstallations. For FCM registration token handling, use FirebaseMessaging. (#6585)
3+
14
# 2020-08 -- 4.6.0
25
- [added] Added a new notification listening token refresh from Messaging and update the token cache in InstanceID. (#6286)
36
- [fixed] Fixed an issue that token refresh notification is not triggered when use `tokenWithAuthorizedEntity:scope:options:handler` to get token. (#6286)

Firebase/InstanceID/FIRInstanceID+Private.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ @interface FIRInstanceID ()
3131

3232
@end
3333

34+
#pragma clang diagnostic push
35+
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
3436
@implementation FIRInstanceID (Private)
37+
#pragma clang diagnostic pop
3538

3639
// This method just wraps our pre-configured auth service to make the request.
3740
// This method is only needed by first-party users, like Remote Config.

Firebase/InstanceID/FIRInstanceID.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ @protocol FIRInstanceIDInstanceProvider
132132
@interface FIRInstanceID () <FIRInstanceIDInstanceProvider, FIRLibrary>
133133
@end
134134

135+
#pragma clang diagnostic push
136+
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
135137
@implementation FIRInstanceIDResult
138+
#pragma clang diagnostic pop
136139
- (id)copyWithZone:(NSZone *)zone {
137140
FIRInstanceIDResult *result = [[[self class] allocWithZone:zone] init];
138141
result.instanceID = self.instanceID;
@@ -141,7 +144,10 @@ - (id)copyWithZone:(NSZone *)zone {
141144
}
142145
@end
143146

147+
#pragma clang diagnostic push
148+
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
144149
@implementation FIRInstanceID
150+
#pragma clang diagnostic pop
145151

146152
// File static to support InstanceID tests that call [FIRInstanceID instanceID] after
147153
// [FIRInstanceID instanceIDForTests].

Firebase/InstanceID/FIRInstanceIDUtilities.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ BOOL FIRInstanceIDHasLocaleChanged() {
144144
#pragma mark - Helpers
145145

146146
BOOL FIRInstanceIDIsValidGCMScope(NSString *scope) {
147+
#pragma clang diagnostic push
148+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
147149
return [scope compare:kFIRInstanceIDScopeFirebaseMessaging
148150
options:NSCaseInsensitiveSearch] == NSOrderedSame;
151+
#pragma clang diagnostic pop
149152
}
150153

151154
NSString *FIRInstanceIDStringForAPNSDeviceToken(NSData *deviceToken) {

Firebase/InstanceID/Public/FIRInstanceID.h

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
2525
* The scope to be used when fetching/deleting a token for Firebase Messaging.
2626
*/
2727
FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
28-
NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging);
28+
NS_SWIFT_NAME(InstanceIDScopeFirebaseMessaging) DEPRECATED_ATTRIBUTE;
2929

3030
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
3131
/**
@@ -37,7 +37,7 @@ FOUNDATION_EXPORT NSString *const kFIRInstanceIDScopeFirebaseMessaging
3737
* to control the rate of token updates on application servers.
3838
*/
3939
FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotification
40-
NS_SWIFT_NAME(InstanceIDTokenRefresh);
40+
NS_SWIFT_NAME(InstanceIDTokenRefresh) DEPRECATED_ATTRIBUTE;
4141
#else
4242
/**
4343
* Called when the system determines that tokens need to be refreshed.
@@ -48,7 +48,7 @@ FOUNDATION_EXPORT const NSNotificationName kFIRInstanceIDTokenRefreshNotificatio
4848
* to control the rate of token updates on application servers.
4949
*/
5050
FOUNDATION_EXPORT NSString *const kFIRInstanceIDTokenRefreshNotification
51-
NS_SWIFT_NAME(InstanceIDTokenRefreshNotification);
51+
NS_SWIFT_NAME(InstanceIDTokenRefreshNotification) DEPRECATED_ATTRIBUTE;
5252
#endif // defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
5353

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

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

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

211219
/**
212220
* Returns a token that authorizes an Entity (example: cloud service) to perform
@@ -250,7 +258,8 @@ NS_SWIFT_NAME(InstanceID)
250258
- (void)tokenWithAuthorizedEntity:(NSString *)authorizedEntity
251259
scope:(NSString *)scope
252260
options:(nullable NSDictionary *)options
253-
handler:(FIRInstanceIDTokenHandler)handler;
261+
handler:(FIRInstanceIDTokenHandler)handler
262+
__deprecated_msg("Use Messaging.token(completion:) instead.");
254263

255264
/**
256265
* Revokes access to a scope (action) for an entity previously
@@ -273,7 +282,8 @@ NS_SWIFT_NAME(InstanceID)
273282
*/
274283
- (void)deleteTokenWithAuthorizedEntity:(NSString *)authorizedEntity
275284
scope:(NSString *)scope
276-
handler:(FIRInstanceIDDeleteTokenHandler)handler;
285+
handler:(FIRInstanceIDDeleteTokenHandler)handler
286+
__deprecated_msg("Use `Messaging.deleteToken(completion:)` instead.");
277287

278288
#pragma mark - Identity
279289

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

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

310325
@end
311326

FirebaseInstanceID.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseInstanceID'
3-
s.version = '4.7.0'
3+
s.version = '4.8.0'
44
s.summary = 'Firebase InstanceID'
55

66
s.description = <<-DESC

FirebaseMessaging.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseMessaging'
3-
s.version = '4.7.0'
3+
s.version = '4.7.1'
44
s.summary = 'Firebase Messaging'
55

66
s.description = <<-DESC

FirebaseMessaging/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2020-09 -- v.4.7.1
2+
- [added] InstanceID is deprecated, add macro to suppress deprecation warning. (#6585)
3+
14
# 2020-09 -- v.4.7.0
25
- [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)
36

0 commit comments

Comments
 (0)