Niladri Paul
Niladri Paul

Reputation: 101

Send welcome email to new users of a Flutter app

I have a flutter app with firebase authentication of Google SignIn and Facebook SignIn. I want to send an email to the new users of my app. How to implement that? What are the services I need to use for it?

Upvotes: 2

Views: 3835

Answers (1)

Dennis Alund
Dennis Alund

Reputation: 3159

You can create a cloud function trigger that creates a user document in a "users collection" when the account is created.

export const createUserDoc = functions.auth.user().onCreate(event => {
    const firebaseUser = event.data;
    const user = {
        name: firebaseUser.displayName || "No Name",
        email: firebaseUser.email
    };

    return firebase.firestore()
        .collection("users")
        .doc(firebaseUser.uid)
        .set(user);
});

After that, the easiest way you could get it setup is to use the Firebase Extension to send email: https://firebase.google.com/products/extensions/firestore-send-email

Upvotes: 4

Related Questions