[go: nahoru, domu]

Skip to content

Commit

Permalink
remove deprecated token API (#2741)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotteliang authored and Corrob committed Apr 22, 2019
1 parent 5a0bb57 commit 086b3ba
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
11 changes: 1 addition & 10 deletions Example/InstanceID/Tests/FIRInstanceIDTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptionsInternal.h>
#import <FirebaseInstanceID/FIRInstanceID_Private.h>
#import <OCMock/OCMock.h>

#import "Firebase/InstanceID/FIRInstanceID+Testing.h"
Expand Down Expand Up @@ -535,7 +536,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 +590,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 +667,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 +735,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
3 changes: 2 additions & 1 deletion Firebase/InstanceID/FIRInstanceID+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#import "FIRInstanceIDCheckinService.h"

/**
* Internal API used by other Firebase SDK teams, including Messaging, Analytics and Remote config.
* Internal API used by Firebase SDK teams by calling in reflection or internal teams.
*/
// TODO(chliangGoogle) Rename this to Internal.
@interface FIRInstanceID (Private)

/**
Expand Down
9 changes: 0 additions & 9 deletions Firebase/InstanceID/FIRInstanceID.m
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,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 @@ -706,20 +703,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
32 changes: 32 additions & 0 deletions Firebase/InstanceID/Private/FIRInstanceID_Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2019 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <FirebaseInstanceID/FIRInstanceID.h>

/**
* Private API used by other Firebase SDKs.
*/
@interface FIRInstanceID ()

/**
* 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
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/FIRInstanceID_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
1 change: 1 addition & 0 deletions FirebaseInstanceID.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services.
s.source_files = base_dir + '**/*.[mh]'
s.requires_arc = base_dir + '*.m'
s.public_header_files = base_dir + 'Public/*.h'
s.private_header_files = base_dir + 'Private/*.h'
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'GCC_PREPROCESSOR_DEFINITIONS' =>
Expand Down

0 comments on commit 086b3ba

Please sign in to comment.