@@ -582,14 +582,14 @@ - (void)internalSignInAndRetrieveDataWithEmail:(NSString *)email
582
582
callback: completion];
583
583
}
584
584
585
- /* * @fn signInWithGameCenterCredential :callback:
585
+ /* * @fn signInAndRetrieveDataWithGameCenterCredential :callback:
586
586
@brief Signs in using a game center credential.
587
587
@param credential The Game Center Auth Credential used to sign in.
588
588
@param callback A block which is invoked when the sign in finished (or is cancelled). Invoked
589
589
asynchronously on the global auth work queue in the future.
590
590
*/
591
- - (void )signInWithGameCenterCredential : (FIRGameCenterAuthCredential *)credential
592
- callback : (FIRAuthResultCallback )callback {
591
+ - (void )signInAndRetrieveDataWithGameCenterCredential : (FIRGameCenterAuthCredential *)credential
592
+ callback : (FIRAuthDataResultCallback )callback {
593
593
FIRSignInWithGameCenterRequest *request =
594
594
[[FIRSignInWithGameCenterRequest alloc ] initWithPlayerID: credential.playerID
595
595
publicKeyURL: credential.publicKeyURL
@@ -601,19 +601,31 @@ - (void)signInWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
601
601
[FIRAuthBackend signInWithGameCenter: request
602
602
callback: ^(FIRSignInWithGameCenterResponse *_Nullable response,
603
603
NSError *_Nullable error) {
604
- if (error) {
605
- if (callback) {
606
- callback (nil , error);
607
- }
608
- return ;
609
- }
604
+ if (error) {
605
+ if (callback) {
606
+ callback (nil , error);
607
+ }
608
+ return ;
609
+ }
610
610
611
- [self completeSignInWithAccessToken: response.IDToken
612
- accessTokenExpirationDate: response.approximateExpirationDate
613
- refreshToken: response.refreshToken
614
- anonymous: NO
615
- callback: callback];
616
- }];
611
+ [self completeSignInWithAccessToken: response.IDToken
612
+ accessTokenExpirationDate: response.approximateExpirationDate
613
+ refreshToken: response.refreshToken
614
+ anonymous: NO
615
+ callback: ^(FIRUser *_Nullable user, NSError *_Nullable error) {
616
+ FIRAdditionalUserInfo *additionalUserInfo =
617
+ [[FIRAdditionalUserInfo alloc ] initWithProviderID: FIRGameCenterAuthProviderID
618
+ profile: nil
619
+ username: nil
620
+ isNewUser: response.isNewUser];
621
+ FIRAuthDataResult *result = user ?
622
+ [[FIRAuthDataResult alloc ] initWithUser: user
623
+ additionalUserInfo: additionalUserInfo] : nil ;
624
+ if (callback) {
625
+ callback (result, error);
626
+ }
627
+ }];
628
+ }];
617
629
}
618
630
619
631
/* * @fn internalSignInAndRetrieveDataWithEmail:link:completion:
@@ -749,16 +761,8 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
749
761
750
762
if ([credential isKindOfClass: [FIRGameCenterAuthCredential class ]]) {
751
763
// Special case for Game Center credentials.
752
- [self signInWithGameCenterCredential: (FIRGameCenterAuthCredential *)credential
753
- callback: ^(FIRUser *_Nullable user, NSError *_Nullable error) {
754
- if (callback) {
755
- FIRAuthDataResult *result;
756
- if (user) {
757
- result = [[FIRAuthDataResult alloc ] initWithUser: user additionalUserInfo: nil ];
758
- }
759
- callback (result, error);
760
- }
761
- }];
764
+ [self signInAndRetrieveDataWithGameCenterCredential: (FIRGameCenterAuthCredential *)credential
765
+ callback: callback];
762
766
return ;
763
767
}
764
768
0 commit comments