Skip to content

Commit

Permalink
feat(auth, ios): fix an iOS crash when using Sign In With Apple due t…
Browse files Browse the repository at this point in the history
…o invalid return of nil instead of NSNull (#9644)
  • Loading branch information
Lyokone committed Oct 3, 2022
1 parent 40abf93 commit 3f76b53
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -1676,15 +1676,23 @@ + (id)getNSDictionaryFromAuthCredential:(FIRAuthCredential *)authCredential {
return [NSNull null];
}

NSString *accessToken = nil;
if ([authCredential isKindOfClass:[FIROAuthCredential class]]) {
if (((FIROAuthCredential *)authCredential).accessToken != nil) {
accessToken = ((FIROAuthCredential *)authCredential).accessToken;
} else if (((FIROAuthCredential *)authCredential).IDToken != nil) {
// For Sign In With Apple, the token is stored in IDToken
accessToken = ((FIROAuthCredential *)authCredential).IDToken;
}
}

return @{
kArgumentProviderId : authCredential.provider,
// Note: "signInMethod" does not exist on iOS SDK, so using provider
// instead.
kArgumentSignInMethod : authCredential.provider,
kArgumentToken : @([authCredential hash]),
kArgumentAccessToken : ([authCredential isKindOfClass:[FIROAuthCredential class]])
? ((FIROAuthCredential *)authCredential).accessToken
: nil,
kArgumentAccessToken : accessToken ?: [NSNull null],
};
}

Expand Down

0 comments on commit 3f76b53

Please sign in to comment.