Skip to content

Fix a bug where sign in with Game Center doesn’t return additional us… #2368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Changes from all commits
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
54 changes: 29 additions & 25 deletions Firebase/Auth/Source/FIRAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ - (void)internalSignInAndRetrieveDataWithEmail:(NSString *)email
callback:completion];
}

/** @fn signInWithGameCenterCredential:callback:
/** @fn signInAndRetrieveDataWithGameCenterCredential:callback:
@brief Signs in using a game center credential.
@param credential The Game Center Auth Credential used to sign in.
@param callback A block which is invoked when the sign in finished (or is cancelled). Invoked
asynchronously on the global auth work queue in the future.
*/
- (void)signInWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
callback:(FIRAuthResultCallback)callback {
- (void)signInAndRetrieveDataWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
callback:(FIRAuthDataResultCallback)callback {
FIRSignInWithGameCenterRequest *request =
[[FIRSignInWithGameCenterRequest alloc] initWithPlayerID:credential.playerID
publicKeyURL:credential.publicKeyURL
Expand All @@ -601,19 +601,31 @@ - (void)signInWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
[FIRAuthBackend signInWithGameCenter:request
callback:^(FIRSignInWithGameCenterResponse *_Nullable response,
NSError *_Nullable error) {
if (error) {
if (callback) {
callback(nil, error);
}
return;
}
if (error) {
if (callback) {
callback(nil, error);
}
return;
}

[self completeSignInWithAccessToken:response.IDToken
accessTokenExpirationDate:response.approximateExpirationDate
refreshToken:response.refreshToken
anonymous:NO
callback:callback];
}];
[self completeSignInWithAccessToken:response.IDToken
accessTokenExpirationDate:response.approximateExpirationDate
refreshToken:response.refreshToken
anonymous:NO
callback:^(FIRUser *_Nullable user, NSError *_Nullable error) {
FIRAdditionalUserInfo *additionalUserInfo =
[[FIRAdditionalUserInfo alloc] initWithProviderID:FIRGameCenterAuthProviderID
profile:nil
username:nil
isNewUser:response.isNewUser];
FIRAuthDataResult *result = user ?
[[FIRAuthDataResult alloc] initWithUser:user
additionalUserInfo:additionalUserInfo] : nil;
if (callback) {
callback(result, error);
}
}];
}];
}

/** @fn internalSignInWithEmail:link:completion:
Expand Down Expand Up @@ -725,16 +737,8 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent

if ([credential isKindOfClass:[FIRGameCenterAuthCredential class]]) {
// Special case for Game Center credentials.
[self signInWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
callback:^(FIRUser *_Nullable user, NSError *_Nullable error) {
if (callback) {
FIRAuthDataResult *result;
if (user) {
result = [[FIRAuthDataResult alloc] initWithUser:user additionalUserInfo:nil];
}
callback(result, error);
}
}];
[self signInAndRetrieveDataWithGameCenterCredential:(FIRGameCenterAuthCredential *)credential
callback:callback];
return;
}

Expand Down