Hi,
Trying apple sign in on the simulator, if I hide email but decide to share my name, I don't get the user's name at all.
displayName is null
username is null, etc.
Am I missing something? Does hiding email always hide a user's name?
unknown, you might be the authority on this if you double-check the Obj-C directly ( good sample code here https://developer.apple.com/documentation/authenticationservices/implementing_user_authentication_with_sign_in_with_apple ) and probe the various bits. Also worth checking the apple developer forums though it seems (based on an issue I had last week, and searches I made) that not many have explored it much yet
Hi @harrisrobin It looks that you are getting the displayName from the Firebase user credential because the Apple credential itself doesn't return any field named displayName, as Firebase does.
If that's your case, I was having the same issue, and I found that the user's name is not returned in Apple's token (as exposed here) so Firebase is not able to get that. But if you need the user's name, you can get it from the Apple credential that is returned by appleAuth.performRequest() as you can see here in the API Docs.
So basically, you can do:
const responseObject = await appleAuth.performRequest({
requestedOperation: AppleAuthRequestOperation.LOGIN,
requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
});
And then get the info you need from:
responseObject.fullname.familyName
responseObject.fullname.givenName
responseObject.fullname.middleName
responseObject.fullname.namePrefix
responseObject.fullname.nameSuffix
responseObject.fullname.nickname
And then manually upload it to Firebase, or replace the displayName or do what you need with the name.
Remember that this info is only returned the first time the user signs in, as exposed in #17.
Hi @harrisrobin It looks that you are getting the
displayNamefrom the Firebase user credential because the Apple credential itself doesn't return any field nameddisplayName, as Firebase does.If that's your case, I was having the same issue, and I found that the user's name is not returned in Apple's token (as exposed here) so Firebase is not able to get that. But if you need the user's name, you can get it from the Apple credential that is returned by
appleAuth.performRequest()as you can see here in the API Docs.So basically, you can do:
const responseObject = await appleAuth.performRequest({ requestedOperation: AppleAuthRequestOperation.LOGIN, requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME], });And then get the info you need from:
responseObject.fullname.familyName responseObject.fullname.givenName responseObject.fullname.middleName responseObject.fullname.namePrefix responseObject.fullname.nameSuffix responseObject.fullname.nicknameAnd then manually upload it to Firebase, or replace the
displayNameor do what you need with the name.Remember that this info is only returned the first time the user signs in, as exposed in #17.
That worked, thank you 馃憤
Most helpful comment
Hi @harrisrobin It looks that you are getting the
displayNamefrom the Firebase user credential because the Apple credential itself doesn't return any field nameddisplayName, as Firebase does.If that's your case, I was having the same issue, and I found that the user's name is not returned in Apple's token (as exposed here) so Firebase is not able to get that. But if you need the user's name, you can get it from the Apple credential that is returned by
appleAuth.performRequest()as you can see here in the API Docs.So basically, you can do:
And then get the info you need from:
And then manually upload it to Firebase, or replace the
displayNameor do what you need with the name.Remember that this info is only returned the first time the user signs in, as exposed in #17.