I try to implement .onCreate
firebase cloud function like in Firebase cloud functions codeLab (https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/#7)
exports.addWelcomeMessages = functions.auth.user().onCreate(event => {
const user = event.data;
console.log('user: %j', user);
const fullName = user.displayName;
return admin.database().ref('messages').push({
name: 'Firebase Bot',
text: `${fullName} signed in for the first time! Welcome!`
});
});
In my client iOS application I use email authentication flow via FirebaseUI, that requires user to enter his email, name and password to sign up. After user signed up, .onCreate
trigger in cloud functions fires, but user
structure does not contain displayName
data:
user: {"email":"my@gmail.com","metadata":{"createdAt":"2017-04-05T05:30:05.000Z","lastSignedInAt":"2017-04-05T05:30:05.000Z"},"uid":"wpIPNvf2suQdMumsEyXA5lQatt23"}
Notice: displayName
property in FIRUser
instance of current user in iOS app is filled correctly just after sign up process.
My assume that it is some kind of a bug in FirebaseUI that firstly creates an empty user with email, fires .onCreate
trigger and only after this fills displayName
property. Is it?
If not, what can be the cause of it?