Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 0 additions & 10 deletions Example/InstanceID/Tests/FIRInstanceIDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ - (void)testDefaultToken_validCachedToken {
[[[self.mockTokenManager stub] andReturn:sTokenInfo]
cachedTokenInfoWithAuthorizedEntity:kAuthorizedEntity
scope:@"*"];

[[self.mockInstanceID reject] defaultTokenWithHandler:nil];
NSString *token = [self.mockInstanceID token];
XCTAssertEqualObjects(token, kToken);
Expand Down Expand Up @@ -590,10 +589,7 @@ - (void)testDefaultTokenFetch_returnValidToken {
cachedTokenInfo = sTokenInfo;

notificationPostCount++;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
notificationToken = [[self.instanceID token] copy];
#pragma clang diagnostic pop
[defaultTokenExpectation fulfill];
}];

Expand Down Expand Up @@ -670,10 +666,7 @@ - (void)testDefaultTokenFetch_retryFetchToken {
cachedTokenInfo = sTokenInfo;

notificationPostCount++;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
notificationToken = [[self.instanceID token] copy];
#pragma clang diagnostic pop
[defaultTokenExpectation fulfill];
}];

Expand Down Expand Up @@ -741,10 +734,7 @@ - (void)testDefaultToken_multipleInvocations {
cachedTokenInfo = sTokenInfo;

notificationPostCount++;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
notificationToken = [[self.instanceID token] copy];
#pragma clang diagnostic pop
[defaultTokenExpectation fulfill];
}];

Expand Down
8 changes: 8 additions & 0 deletions Firebase/InstanceID/FIRInstanceID+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@
*/
- (nullable NSString *)appInstanceID:(NSError *_Nullable *_Nullable)error;

/**
* Returns a Firebase Messaging scoped token for the firebase app.
*
* @return Returns the stored token if the device has registered with Firebase Messaging, otherwise
* returns nil.
*/
- (nullable NSString *)token;

@end
9 changes: 0 additions & 9 deletions Firebase/InstanceID/FIRInstanceID.m
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,7 @@ - (void)getIDWithHandler:(FIRInstanceIDHandler)handler {
// When getID is explicitly called, trigger getToken to make sure token always exists.
// This is to avoid ID conflict (ID is not checked for conflict until we generate a token)
if (appIdentity) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self token];
#pragma clang diagnostic pop
}
callHandlerOnMainThread(appIdentity, error);
});
Expand Down Expand Up @@ -707,20 +704,14 @@ - (void)didCompleteConfigure {
[self defaultTokenWithHandler:nil];
}
// Notify FCM with the default token.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.defaultFCMToken = [self token];
#pragma clang diagnostic pop
} else if ([self isFCMAutoInitEnabled]) {
// When there is no cached token, must check auto init is enabled.
// If it's disabled, don't initiate token generation/refresh.
// If no cache token and auto init is enabled, fetch a token from server.
[self defaultTokenWithHandler:nil];
// Notify FCM with the default token.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.defaultFCMToken = [self token];
#pragma clang diagnostic pop
}
// ONLY checkin when auto data collection is turned on.
if ([self isFCMAutoInitEnabled]) {
Expand Down
8 changes: 0 additions & 8 deletions Firebase/InstanceID/Public/FIRInstanceID.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,6 @@ NS_SWIFT_NAME(InstanceID)
*/
- (void)instanceIDWithHandler:(FIRInstanceIDResultHandler)handler;

/**
* Returns a Firebase Messaging scoped token for the firebase app.
*
* @return Returns the stored token if the device has registered with Firebase Messaging, otherwise
* returns nil.
*/
- (nullable NSString *)token __deprecated_msg("Use instanceIDWithHandler: instead.");

/**
* Returns a token that authorizes an Entity (example: cloud service) to perform
* an action on behalf of the application identified by Instance ID.
Expand Down
10 changes: 1 addition & 9 deletions Firebase/Messaging/FIRMessaging.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#import <FirebaseCore/FIRDependency.h>
#import <FirebaseCore/FIRLibrary.h>
#import <FirebaseInstanceID/FirebaseInstanceID.h>
#import <FirebaseInstanceID/FirebaseInstanceID+Private.h>
#import <GoogleUtilities/GULReachabilityChecker.h>
#import <GoogleUtilities/GULUserDefaults.h>

Expand Down Expand Up @@ -556,21 +557,15 @@ - (void)setAutoInitEnabled:(BOOL)autoInitEnabled {
forKey:kFIRMessagingUserDefaultsKeyAutoInitEnabled];
[_messagingUserDefaults synchronize];
if (!isFCMAutoInitEnabled && autoInitEnabled) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
self.defaultFcmToken = self.instanceID.token;
#pragma clang diagnostic pop
}
}

- (NSString *)FCMToken {
NSString *token = self.defaultFcmToken;
if (!token) {
// We may not have received it from Instance ID yet (via NSNotification), so extract it directly
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
token = self.instanceID.token;
#pragma clang diagnostic pop
}
return token;
}
Expand Down Expand Up @@ -918,10 +913,7 @@ - (void)didReceiveDefaultInstanceIDToken:(NSNotification *)notification {

- (void)defaultInstanceIDTokenWasRefreshed:(NSNotification *)notification {
// Retrieve the Instance ID default token, and if it is non-nil, post it
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSString *token = self.instanceID.token;
#pragma clang diagnostic pop
// Sometimes Instance ID doesn't yet have a token, so wait until the default
// token is fetched, and then notify. This ensures that this token should not
// be nil when the developer accesses it.
Expand Down