[go: nahoru, domu]

Skip to content

Commit

Permalink
Remove deprecated -[FIRInstanceID appInstanceID:] (#6677)
Browse files Browse the repository at this point in the history
* Remove deprecated -[FIRInstanceID appInstanceID:]

* changelog

* typo fix
  • Loading branch information
maksymmalyhin committed Oct 6, 2020
1 parent 8e276e9 commit 8eded3f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 141 deletions.
78 changes: 0 additions & 78 deletions Example/InstanceID/Tests/FIRInstanceIDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ - (void)testSharedInstance {
// The shared instance should be `nil` before the app is configured.
XCTAssertNil([FIRInstanceID instanceID]);

// Expect FID to be requested at the start.
[self expectInstallationsInstallationIDWithFID:@"fid" error:nil];

// The shared instance relies on the default app being configured. Configure it.
FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID
GCMSenderID:kGCMSenderID];
Expand All @@ -176,85 +173,10 @@ - (void)testSharedInstance {
FIRInstanceID *secondInstanceID = [FIRInstanceID instanceID];
XCTAssertEqualObjects(instanceID, secondInstanceID);

// Verify FirebaseInstallations requested for FID.
OCMVerifyAll(self.mockInstallations);

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

// Reset the default app for the next test.
[FIRApp resetApps];
}

- (void)testSyncAppInstanceIDIsUpdatedOnFIDUpdateNotificationIfAppIDMatches {
NSString *firebaseAppID = @"firebaseAppID";
_instanceID.firebaseAppID = firebaseAppID;

[self expectInstallationsInstallationIDWithFID:@"fid-1" error:nil];
// Simulate FID update notification.
[[NSNotificationCenter defaultCenter]
postNotificationName:FIRInstallationIDDidChangeNotification
object:nil
userInfo:@{kFIRInstallationIDDidChangeNotificationAppNameKey : firebaseAppID}];

OCMVerifyAll(self.mockInstallations);
NSError *error = nil;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqualObjects([self.instanceID appInstanceID:&error], @"fid-1");
#pragma clang diagnostic pop
XCTAssertNil(error);

[self expectInstallationsInstallationIDWithFID:@"fid-2" error:nil];
// Simulate FID update notification.
[[NSNotificationCenter defaultCenter]
postNotificationName:FIRInstallationIDDidChangeNotification
object:nil
userInfo:@{kFIRInstallationIDDidChangeNotificationAppNameKey : firebaseAppID}];

OCMVerifyAll(self.mockInstallations);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqualObjects([self.instanceID appInstanceID:&error], @"fid-2");
#pragma clang diagnostic pop
XCTAssertNil(error);
}

- (void)testSyncAppInstanceIDIsNotUpdatedOnFIDUpdateNotificationIfAppIDMismatches {
NSString *firebaseAppID = @"firebaseAppID";
_instanceID.firebaseAppID = firebaseAppID;

[self expectInstallationsInstallationIDWithFID:@"fid-1" error:nil];
// Simulate FID update notification.
[[NSNotificationCenter defaultCenter]
postNotificationName:FIRInstallationIDDidChangeNotification
object:nil
userInfo:@{kFIRInstallationIDDidChangeNotificationAppNameKey : firebaseAppID}];

OCMVerifyAll(self.mockInstallations);
NSError *error = nil;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqualObjects([self.instanceID appInstanceID:&error], @"fid-1");
#pragma clang diagnostic pop
XCTAssertNil(error);

OCMReject([self.mockInstallations installationIDWithCompletion:[OCMArg any]]);
// Simulate FID update notification.
NSString *differentAppID = [firebaseAppID stringByAppendingString:@"different"];
[[NSNotificationCenter defaultCenter]
postNotificationName:FIRInstallationIDDidChangeNotification
object:nil
userInfo:@{kFIRInstallationIDDidChangeNotificationAppNameKey : differentAppID}];

OCMVerifyAll(self.mockInstallations);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqualObjects([self.instanceID appInstanceID:&error], @"fid-1");
#pragma clang diagnostic pop
XCTAssertNil(error);
}

- (void)testFCMAutoInitEnabled {
XCTAssertFalse([_instanceID isFCMAutoInitEnabled],
@"When FCM is not available, FCM Auto Init Enabled should be NO.");
Expand Down
3 changes: 3 additions & 0 deletions Firebase/InstanceID/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased -- 7.0.0
- [changed] Deprecated private `-[FIRInstanceID appInstanceID:]` method was removed. (#4486)

# 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)

Expand Down
7 changes: 0 additions & 7 deletions Firebase/InstanceID/FIRInstanceID+Private.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import "FirebaseInstallations/Source/Library/Private/FirebaseInstallationsInternal.h"

#import "Firebase/InstanceID/FIRInstanceIDAuthService.h"
#import "Firebase/InstanceID/FIRInstanceIDDefines.h"
#import "Firebase/InstanceID/FIRInstanceIDTokenManager.h"
#import "Firebase/InstanceID/Private/FIRInstanceID_Private.h"

Expand All @@ -42,12 +41,6 @@ - (void)fetchCheckinInfoWithHandler:(FIRInstanceIDDeviceCheckinCompletion)handle
[self.tokenManager.authService fetchCheckinInfoWithHandler:handler];
}

// TODO(#4486): Delete the method, `self.firebaseInstallationsID` and related
// code for Firebase 7 release.
- (NSString *)appInstanceID:(NSError **)outError {
return self.firebaseInstallationsID;
}

#pragma mark - Firebase Installations Compatibility

/// Presence of this method indicates that this version of IID uses FirebaseInstallations under the
Expand Down
37 changes: 0 additions & 37 deletions Firebase/InstanceID/FIRInstanceID.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ @interface FIRInstanceID ()
@property(atomic, strong, nullable)
FIRInstanceIDCombinedHandler<NSString *> *defaultTokenFetchHandler;

/// A cached value of FID. Should be used only for `-[FIRInstanceID appInstanceID:]`.
@property(atomic, copy, nullable) NSString *firebaseInstallationsID;

@end

// InstanceID doesn't provide any functionality to other components,
Expand Down Expand Up @@ -625,8 +622,6 @@ - (void)configureInstanceIDWithOptions:(FIROptions *)options {
self.fcmSenderID = GCMSenderID;
self.firebaseAppID = options.googleAppID;

[self updateFirebaseInstallationID];

// FCM generates a FCM token during app start for sending push notification to device.
// This is not needed for app extension except for watch.
#if TARGET_OS_WATCH
Expand Down Expand Up @@ -719,7 +714,6 @@ - (void)setupNotificationListeners {
selector:@selector(notifyAPNSTokenIsSet:)
name:kFIRInstanceIDAPNSTokenNotification
object:nil];
[self observeFirebaseInstallationIDChanges];
[self observeFirebaseMessagingTokenChanges];
}

Expand Down Expand Up @@ -1098,37 +1092,6 @@ - (void)logAPNSConfigurationError:(NSString *)errorString {
}
}

#pragma mark - Sync InstanceID

- (void)updateFirebaseInstallationID {
FIRInstanceID_WEAKIFY(self);
[self.installations
installationIDWithCompletion:^(NSString *_Nullable installationID, NSError *_Nullable error) {
FIRInstanceID_STRONGIFY(self);
self.firebaseInstallationsID = installationID;
}];
}

- (void)installationIDDidChangeNotificationReceived:(NSNotification *)notification {
NSString *installationAppID =
notification.userInfo[kFIRInstallationIDDidChangeNotificationAppNameKey];
if ([installationAppID isKindOfClass:[NSString class]] &&
[installationAppID isEqual:self.firebaseAppID]) {
[self updateFirebaseInstallationID];
}
}

- (void)observeFirebaseInstallationIDChanges {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:FIRInstallationIDDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(installationIDDidChangeNotificationReceived:)
name:FIRInstallationIDDidChangeNotification
object:nil];
}

- (void)observeFirebaseMessagingTokenChanges {
[[NSNotificationCenter defaultCenter]
removeObserver:self
Expand Down
16 changes: 0 additions & 16 deletions Firebase/InstanceID/Private/FIRInstanceID+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,4 @@ typedef void (^FIRInstanceIDDeviceCheckinCompletion)(
*/
- (void)fetchCheckinInfoWithHandler:(nullable FIRInstanceIDDeviceCheckinCompletion)handler;

/**
* Get the InstanceID for the app. If an ID was created before and cached
* successfully we will return that ID. If no cached ID exists we create
* a new ID, cache it and return that.
*
* This is a blocking call and should not really be called on the main thread.
*
* @param error The error object that represents the error while trying to
* retrieve the instance id.
*
* @return The InstanceID for the app.
*/
- (nullable NSString *)appInstanceID:(NSError *_Nullable *_Nullable)error
DEPRECATED_MSG_ATTRIBUTE("Please use getID(handler:) for Swift or "
"getIDWithHandler: for Objective-C instead.");

@end
3 changes: 0 additions & 3 deletions Firebase/InstanceID/Private/FIRInstanceID_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ NS_ASSUME_NONNULL_BEGIN

@property(nonatomic, readonly, strong) FIRInstallations *installations;

/// A cached value of FID. Should be used only for `-[FIRInstanceID appInstanceID:]`.
@property(atomic, readonly, copy, nullable) NSString *firebaseInstallationsID;

/**
* Private initializer.
*/
Expand Down

0 comments on commit 8eded3f

Please sign in to comment.