validaciones de inputs

This commit is contained in:
Juan Felipe Duarte
2023-05-12 16:56:43 -05:00
parent d5702207d2
commit 4b1e214742
23 changed files with 8566 additions and 207 deletions
+36
View File
@@ -0,0 +1,36 @@
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
admin.initializeApp();
const fcm = admin.messaging();
exports.checkhealth = functions.https.onCall(async (data, context) => {
return "The function is online";
});
exports.sendNotification = functions.https.onCall(async (data, context) => {
const title = data.title;
const body = data.body;
const token = data.token;
try {
const payload = {
token: token,
notification: {
title: title,
body: body,
},
data: {
body: body,
},
};
return fcm.send(payload).then((response) => {
return {success: true, response: "Succefully sent message: " + response};
}).catch((error) => {
return {error: error};
});
} catch (error) {
throw new functions.https.HttpsError("invalid-argument", "error:" + error);
}
});