I have an android app with Firebase database in which I connected a node.js with Cloud Firestore. Below is the code in node:
const admin = require('firebase-admin');
const serviceAccount = require('./ServiceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const db = admin.firestore();
admin
.firestore()
.collection("email_collection")
.add({
to: "[email protected]",
message: {
subject: "Hello from Firebase!",
text: "This is the plaintext section of the email body.",
html: "This is the <code>HTML</code> section of the email body.",
},
})
.then(() => console.log("Queued email for delivery!"));
I have tested it (manually) by running the server from the terminal and I received the email successfully.
Now my question is: how can I run the server from the android app? In other words, there is a button in the app, how can I make the user (when he clicks on that button) triggers the node with some data like email address and then sends email through cloud firestore?
CodePudding user response:
I think you might be looking for callable cloud functions