Skip to content

Commit dae3442

Browse files
author
Chuan Ren
authored
Remove deprecated APIs (#2723)
1 parent 9bdcf3f commit dae3442

File tree

14 files changed

+287
-547
lines changed

14 files changed

+287
-547
lines changed

Example/Auth/ApiTests/FacebookAuthTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ - (void)testSignInWithFaceboook {
5454
XCTestExpectation *expectation = [self expectationWithDescription:@"Facebook sign-in finished."];
5555

5656
[auth signInWithCredential:credential
57-
completion:^(FIRUser *user, NSError *error) {
57+
completion:^(FIRAuthDataResult *result, NSError *error) {
5858
if (error) {
5959
NSLog(@"Facebook sign in error: %@", error);
6060
}
@@ -94,7 +94,7 @@ - (void)testLinkAnonymousAccountToFacebookAccount {
9494

9595
XCTestExpectation *expectation = [self expectationWithDescription:@"Facebook linking finished."];
9696
[auth.currentUser linkWithCredential:credential
97-
completion:^(FIRUser *user, NSError *error) {
97+
completion:^(FIRAuthDataResult *result, NSError *error) {
9898
if (error) {
9999
NSLog(@"Link to Facebok error: %@", error);
100100
}

Example/Auth/ApiTests/GoogleAuthTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ - (void)testSignInWithGoogle {
4848
XCTestExpectation *expectation =
4949
[self expectationWithDescription:@"Signing in with Google finished."];
5050
[auth signInWithCredential:credential
51-
completion:^(FIRUser *user, NSError *error) {
51+
completion:^(FIRAuthDataResult *result, NSError *error) {
5252
if (error) {
5353
NSLog(@"Signing in with Google had error: %@", error);
5454
}

Example/Auth/ApiTests/GoogleAuthTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GoogleAuthTestsSwift: FIRAuthApiTestsBase {
3535
let credential = GoogleAuthProvider.credential(withIDToken: googleIdToken, accessToken: googleAccessToken)
3636

3737
let expectation = self.expectation(description: "Signing in with Google finished.")
38-
auth.signInAndRetrieveData(with: credential) { _, error in
38+
auth.signIn(with: credential) { _, error in
3939
if error != nil {
4040
print("Signing in with Google had error: %@", error!)
4141
}

Example/Auth/Sample/MainViewController.m

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,9 @@ - (void)signInWithProvider:(nonnull id<AuthProvider>)provider callback:(void(^)(
11311131
[self logFailedTest:@"The test needs a valid credential to continue."];
11321132
return;
11331133
}
1134-
[[AppManager auth] signInWithCredential:credential completion:^(FIRUser *_Nullable user,
1135-
NSError *_Nullable error) {
1134+
[[AppManager auth] signInAndRetrieveDataWithCredential:credential
1135+
completion:^(FIRAuthDataResult *_Nullable result,
1136+
NSError *_Nullable error) {
11361137
if (error) {
11371138
[self logFailure:@"sign-in with provider failed" error:error];
11381139
[self logFailedTest:@"Sign-in should succeed"];
@@ -1283,9 +1284,9 @@ - (void)automatedEmailSignUp {
12831284
[auth signOut:NULL];
12841285
FIRAuthCredential *credential = [FIREmailAuthProvider credentialWithEmail:kFakeEmail
12851286
password:kFakePassword];
1286-
[auth signInWithCredential:credential
1287-
completion:^(FIRUser *_Nullable user,
1288-
NSError *_Nullable error) {
1287+
[auth signInAndRetrieveDataWithCredential:credential
1288+
completion:^(FIRAuthDataResult *_Nullable result,
1289+
NSError *_Nullable error) {
12891290
if (error) {
12901291
[self logFailure:@"sign-in with Email/Password failed" error:error];
12911292
[self logFailedTest:@"sign-in with Email/Password should succeed."];
@@ -1381,8 +1382,10 @@ - (void)automatedAccountLinking {
13811382
callback:^(FIRAuthCredential *credential,
13821383
NSError *error) {
13831384
if (credential) {
1384-
[result.user linkWithCredential:credential completion:^(FIRUser *user,
1385+
[result.user linkAndRetrieveDataWithCredential:credential
1386+
completion:^(FIRAuthDataResult *result,
13851387
NSError *error) {
1388+
FIRUser *user = result.user;
13861389
if (error) {
13871390
[self logFailure:@"link auth provider failed" error:error];
13881391
[self logFailedTest:@"Account needs to be linked to complete the test."];
@@ -1573,9 +1576,9 @@ - (void)updateEmailPasswordWithCompletion:(void(^)(void))completion {
15731576
[auth signOut:NULL];
15741577
FIRAuthCredential *credential =
15751578
[FIREmailAuthProvider credentialWithEmail:kFakeEmail password:kFakePassword];
1576-
[auth signInWithCredential:credential
1577-
completion:^(FIRUser *_Nullable user,
1578-
NSError *_Nullable error) {
1579+
[auth signInAndRetrieveDataWithCredential:credential
1580+
completion:^(FIRAuthDataResult *_Nullable result,
1581+
NSError *_Nullable error) {
15791582
if (error) {
15801583
[self logFailure:@"sign-in with Email/Password failed" error:error];
15811584
[self logFailedTest:@"sign-in with Email/Password should succeed."];
@@ -2003,9 +2006,9 @@ - (void)signInEmailPassword {
20032006
[FIREmailAuthProvider credentialWithEmail:email
20042007
password:password];
20052008
[self showSpinner:^{
2006-
[[AppManager auth] signInWithCredential:credential
2007-
completion:^(FIRUser *_Nullable user,
2008-
NSError *_Nullable error) {
2009+
[[AppManager auth] signInAndRetrieveDataWithCredential:credential
2010+
completion:^(FIRAuthDataResult *_Nullable result,
2011+
NSError *_Nullable error) {
20092012
[self hideSpinner:^{
20102013
if (error) {
20112014
[self logFailure:@"sign-in with Email/Password failed" error:error];
@@ -2033,10 +2036,10 @@ - (void)signInEmailPasswordAuthDataResult {
20332036
return;
20342037
}
20352038
[self showSpinner:^{
2036-
[[AppManager auth] signInAndRetrieveDataWithEmail:email
2037-
password:password
2038-
completion:^(FIRAuthDataResult *_Nullable authResult,
2039-
NSError *_Nullable error) {
2039+
[[AppManager auth] signInWithEmail:email
2040+
password:password
2041+
completion:^(FIRAuthDataResult *_Nullable authResult,
2042+
NSError *_Nullable error) {
20402043
[self hideSpinner:^{
20412044
if (error) {
20422045
[self logFailure:@"sign-in with Email/Password failed" error:error];
@@ -2270,8 +2273,9 @@ - (void)reauthenticateEmailPassword {
22702273
}
22712274
[self showEmailPasswordDialogWithCompletion:^(FIRAuthCredential *credential) {
22722275
[self showSpinner:^{
2273-
[[self user] reauthenticateWithCredential:credential
2274-
completion:^(NSError *_Nullable error) {
2276+
[[self user] reauthenticateAndRetrieveDataWithCredential:credential
2277+
completion:^(FIRAuthDataResult *_Nullable result,
2278+
NSError *_Nullable error) {
22752279
if (error) {
22762280
[self logFailure:@"reauthicate with email/password failed" error:error];
22772281
} else {
@@ -2321,13 +2325,14 @@ - (void)reauthenticate:(id<AuthProvider>)authProvider retrieveData:(BOOL)retriev
23212325
}
23222326
[self showTypicalUIForUserUpdateResultsWithTitle:@"Reauthenticate" error:error];
23232327
};
2324-
FIRUserProfileChangeCallback callback = ^(NSError *_Nullable error) {
2328+
FIRAuthDataResultCallback callback = ^(FIRAuthDataResult *_Nullable result,
2329+
NSError *_Nullable error) {
23252330
completion(nil, error);
23262331
};
23272332
if (retrieveData) {
23282333
[user reauthenticateAndRetrieveDataWithCredential:credential completion:completion];
23292334
} else {
2330-
[user reauthenticateWithCredential:credential completion:callback];
2335+
[user reauthenticateAndRetrieveDataWithCredential:credential completion:callback];
23312336
}
23322337
}
23332338
}];
@@ -2367,14 +2372,14 @@ - (void)signinWithProvider:(id<AuthProvider>)authProvider retrieveData:(BOOL)ret
23672372
}
23682373
[self showTypicalUIForUserUpdateResultsWithTitle:@"Sign-In" error:error];
23692374
};
2370-
FIRAuthResultCallback callback = ^(FIRUser *_Nullable user,
2371-
NSError *_Nullable error) {
2375+
FIRAuthDataResultCallback callback = ^(FIRAuthDataResult *_Nullable result,
2376+
NSError *_Nullable error) {
23722377
completion(nil, error);
23732378
};
23742379
if (retrieveData) {
23752380
[auth signInAndRetrieveDataWithCredential:credential completion:completion];
23762381
} else {
2377-
[auth signInWithCredential:credential completion:callback];
2382+
[auth signInAndRetrieveDataWithCredential:credential completion:callback];
23782383
}
23792384
}
23802385
}];
@@ -2551,14 +2556,14 @@ - (void)linkWithAuthProvider:(id<AuthProvider>)authProvider retrieveData:(BOOL)r
25512556
[self showTypicalUIForUserUpdateResultsWithTitle:@"Link Account" error:error];
25522557
}
25532558
};
2554-
FIRAuthResultCallback callback = ^(FIRUser *_Nullable user,
2555-
NSError *_Nullable error) {
2559+
FIRAuthDataResultCallback callback = ^(FIRAuthDataResult *_Nullable result,
2560+
NSError *_Nullable error) {
25562561
completion(nil, error);
25572562
};
25582563
if (retrieveData) {
25592564
[user linkAndRetrieveDataWithCredential:credential completion:completion];
25602565
} else {
2561-
[user linkWithCredential:credential completion:callback];
2566+
[user linkAndRetrieveDataWithCredential:credential completion:callback];
25622567
}
25632568
}
25642569
}];
@@ -2602,8 +2607,8 @@ - (void)linkWithFacebookAndRetrieveData {
26022607
- (void)linkWithEmailPassword {
26032608
[self showEmailPasswordDialogWithCompletion:^(FIRAuthCredential *credential) {
26042609
[self showSpinner:^{
2605-
[[self user] linkWithCredential:credential
2606-
completion:^(FIRUser *user, NSError *_Nullable error) {
2610+
[[self user] linkAndRetrieveDataWithCredential:credential
2611+
completion:^(FIRAuthDataResult *result, NSError *error) {
26072612
if (error) {
26082613
[self logFailure:@"link Email/Password failed" error:error];
26092614
} else {
@@ -3108,10 +3113,10 @@ - (void)createUserAuthDataResult {
31083113
}
31093114

31103115
[self showSpinner:^{
3111-
[[AppManager auth] createUserAndRetrieveDataWithEmail:email
3112-
password:password
3113-
completion:^(FIRAuthDataResult *_Nullable result,
3114-
NSError *_Nullable error) {
3116+
[[AppManager auth] createUserWithEmail:email
3117+
password:password
3118+
completion:^(FIRAuthDataResult *_Nullable result,
3119+
NSError *_Nullable error) {
31153120
if (error) {
31163121
[self logFailure:@"create user failed" error:error];
31173122
} else {
@@ -3378,9 +3383,9 @@ - (void)linkPhoneNumber:(NSString *_Nullable)phoneNumber
33783383
FIRPhoneAuthCredential *credential =
33793384
[[AppManager phoneAuthProvider] credentialWithVerificationID:verificationID
33803385
verificationCode:verificationCode];
3381-
[[self user] linkWithCredential:credential
3382-
completion:^(FIRUser *_Nullable user,
3383-
NSError *_Nullable error) {
3386+
[[self user] linkAndRetrieveDataWithCredential:credential
3387+
completion:^(FIRAuthDataResult *_Nullable result,
3388+
NSError *_Nullable error) {
33843389
[self hideSpinner:^{
33853390
if (error) {
33863391
if (error.code == FIRAuthErrorCodeCredentialAlreadyInUse) {
@@ -3396,9 +3401,9 @@ - (void)linkPhoneNumber:(NSString *_Nullable)phoneNumber
33963401
[self showSpinner:^{
33973402
FIRPhoneAuthCredential *credential =
33983403
error.userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey];
3399-
[[AppManager auth] signInWithCredential:credential
3400-
completion:^(FIRUser *_Nullable user,
3401-
NSError *_Nullable error) {
3404+
[[AppManager auth] signInAndRetrieveDataWithCredential:credential
3405+
completion:^(FIRAuthDataResult *_Nullable result,
3406+
NSError *_Nullable error) {
34023407
[self hideSpinner:^{
34033408
if (error) {
34043409
[self logFailure:@"failed to verify phone number" error:error];
@@ -3467,7 +3472,7 @@ - (void)signInAnonymously {
34673472
success.
34683473
*/
34693474
- (void)signInAnonymouslyAuthDataResult {
3470-
[[AppManager auth] signInAnonymouslyAndRetrieveDataWithCompletion:
3475+
[[AppManager auth] signInAnonymouslyWithCompletion:
34713476
^(FIRAuthDataResult *_Nullable authResult, NSError *_Nullable error) {
34723477
if (error) {
34733478
[self logFailure:@"sign-in anonymously failed" error:error];
@@ -3492,9 +3497,9 @@ - (void)signInWithGitHub {
34923497
FIROAuthCredential *credential =
34933498
[FIROAuthProvider credentialWithProviderID:FIRGitHubAuthProviderID accessToken:accessToken];
34943499
if (credential) {
3495-
[[AppManager auth] signInWithCredential:credential
3496-
completion:^(FIRUser *_Nullable result,
3497-
NSError *_Nullable error) {
3500+
[[AppManager auth] signInAndRetrieveDataWithCredential:credential
3501+
completion:^(FIRAuthDataResult *_Nullable result,
3502+
NSError *_Nullable error) {
34983503
if (error) {
34993504
[self logFailure:@"sign-in with provider failed" error:error];
35003505
} else {
@@ -3660,9 +3665,9 @@ - (void)doSignInWithCustomToken:(NSString *_Nullable)userEnteredTokenText {
36603665
}
36613666

36623667
- (void)doSignInAndRetrieveDataWithCustomToken:(NSString *_Nullable)userEnteredTokenText {
3663-
[[AppManager auth] signInAndRetrieveDataWithCustomToken:userEnteredTokenText
3664-
completion:^(FIRAuthDataResult *_Nullable result,
3665-
NSError *_Nullable error) {
3668+
[[AppManager auth] signInWithCustomToken:userEnteredTokenText
3669+
completion:^(FIRAuthDataResult *_Nullable result,
3670+
NSError *_Nullable error) {
36663671
if (error) {
36673672
[self logFailure:@"sign-in with custom token failed" error:error];
36683673
[self showMessagePromptWithTitle:kSignInErrorAlertTitle

0 commit comments

Comments
 (0)