Admin Notifications in Firebase Firestore - firebase

Is there any easy way admin to get notification whenever a new document added to fire store, we are completed the shopping app with android studio and fire base. user successfully placing orders but admin has to go fire base console and to check if any new order.
please help me to get notified by email or any other method. fire base functions may be the solution but i am completely new to functions.

There is nothing built into Firestore to send an email when a new document is added.
But you can use the Firestore integration with Cloud Functions to trigger such an email. In fact, that is precisely what the Firebase trigger email extension does. It's a click-to-install extension, so I recommend giving that a try and see if it fits your needs.

Related

Flutter firebase trigger email implementation

I've been trying to create a contact form for my flutter project. The contact form is composed of two steps. First, the user provides their email and then describes their issue. Once the user presses submit, I want to receive an email on my end. I've look at several packages like mailer and flutter_email_sender. However, they don't seem to offer good solutions; mailer requires that I provide the password to my email address in my code (opening up the possibility for vulnerabilities). Flutter_email_sender simply opens up an email app on the phone.
Recently I've come across the perfect solution, Firebase's new extension Trigger Email. Although the extension seems promising, I can't find any resources outlining proper implementation of Trigger Email in Flutter.
Can you please provide an example of how Trigger Email can be implemented in Flutter project?
From the documentation of the extension:
Use this extension to render and send emails that contain the information from documents added to a specified Cloud Firestore collection.
So to send an email you write a document to Cloud Firestore. For examples of writing to Cloud Firestore from Flutter, see the FlutterFire documentation for examples of this.

Flutter - Understanding Firebase Admin and how to get a user's information from email/uid/name

I'm making a little Snapchat clone, and a part of this app I'm trying to build is the ability to add a friend and start a conversation with them. I'm using Firebase to manage my users and I'm a little stuck now trying to figure out what works and why I'm getting problems trying to use some methods or functions.
What I want is this simple line of code to work:
var userByEmail = await _admin.app().auth().getUserByEmail("b#gmail.com");
print(userByEmail.toString());
However this has been giving my some problems, most recently, the following error message:
Unhandled Exception: FirebaseAuthError(auth/invalid-credential): Must initialize app with a cert credential or set your Firebase project ID as the GOOGLE_CLOUD_PROJECT environment variable to call verifyIdToken().
Getting to this point made me want to first ask a question about FirebaseAdmin and Auth before continuing and potentially screwing up my app settings.
Is there a simple way to do what I'm trying to do?
I have a Firebase.instance.initializeApp() in my Main function, do I only ever call that once or should I start initilizeApp in the initState of each Stateful Widget where needed?
What does this error message actually mean?
You are trying to use the Firebase Admin SDK in your Flutter code, which is not possible. The Admin SDKs give full administrative access to your Firebase project, which would be a serious security concern if you allow that in your Flutter app.
If you want to allow certain administrative functionality in your application, you will have to make that functionality available yourself. For example, to look up a user by their email address, there are two common approaches:
Store the minimal information about each user in a cloud-accessible database (such as Firebase's Realtime Database or Cloud Firestore) when each user registers with your app, and then look it up from there.
Wrap the getUserByEmail from the Admin SDK in a custom API that you make for yourself, on a server you control or in Cloud Functions. In that API you validate that the user making the call is authorized to do so, then call Firebase through the API you were trying to use, and return the minimal result back to the caller.
Both of these are feasible and can work to solve a variety of use-cases. But if you've never built backend code before, you might find the first approach easier to get started with.
Also see:
How to get Firebase UID knowing email user?
Flutter get User Data from Firebase
The right way to do what you want is using Firebase auth, authenticating your user and using a collection to store and retrieve users information. That auth information provided by firebase should only be used for authentication and security purposes.
The Firebase admin must have a user logged in to work properly, but its purpose is to provide a more administration environment and should not be used inside a clients app, unless its an admin app.
With all that said, lets go for the rescue:
Authenticate your user (using firebase auth);
After auth, save all the user information you want to share with other user inside its own collection (you will need to create one);
When an authenticated user (this is important) 'request any other users data, you query for the data in the previous created collection.

How do I receive mail from React Native app using firebase?

I am creating a "Send Feedback" screen on React Native Expo and I need a way for users to send feedback via a submit form and I need to redirect their emails to my email address. Does anyone have a clue or can offer some direction. Thank you so much for your time.
You can solve it in another way:
First create a collection (feedback) in your Firebase Cloud Firestore. When a user sends the feedback via the submit form, they make an entry in the collection with the data of the feedback.
Then you can create a Firebase Cloud Functions, that executes 1 time everyday and send you an email with the latest new feedbacks. Make sure to check out nodemailer too.

Firebase Mailchimp Extension - Update Subscriber Name

Is there a way to update the subscriber when the user updates their profile with their first/last name? Could that be done with a cloud function if not through the extension?
Thanks in advance
[can this be done] when the user updates their profile with their first/last name
There is currently no Cloud Functions trigger for Firebase Authentication profile updates. This means that there is no way to do this directly with Cloud Functions, and hence also not in the Auth Mailchimp sync Extension, which is based on Cloud Functions functionality.
If you build this functionality yourself (you can use the existing extension source code for inspiration), you can trigger an update of the Mailchimp audience directly from your client-side code when you also call the Firebase Authentication API to update the profile.

Can I modify the template used for Firebase's email link-based authentication?

I'm walking through the steps described here and upon sending the verification email to myself, I get an email in my inbox from noreply#myappname.firebaseapp.com.
For other email-based auth steps, I can customize the sender name and email address directly from the Firebase console:
Am I missing something that could help me with Email Link sign-in or do I need to go through the process of modifying the SMTP settings in my app's console?
I noticed the same behavior / restriction in the Firebase console. Considering that the underlying .firebase.auth().createUserWithEmailAndPassword method could write your new user to firestore, i guess you could use firebase function to trigger a custom email via sendGrid, for example, and you could flesh out a custom workflow from there.
This article, Email via Firebase Firestore Cloud Function Triggers includes the code to trigger custom emails and could be adapted to your needs. I imagine the trick will be to get the .emailValidated property set to true. It may be as easy as switching the boolean - i don't know.
All in all, it seems like a lot of work just to get a customized validation email though. I would recommend you just stick with what they provide.

Resources