From 306c3e52840ee7df6ce7a66571f64fcdbf7b7fd1 Mon Sep 17 00:00:00 2001 From: SECAP-670 Date: Mon, 31 Mar 2025 18:08:39 -0400 Subject: [PATCH 1/2] Firebase functions --- stml_functions/functions/index.js | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 stml_functions/functions/index.js diff --git a/stml_functions/functions/index.js b/stml_functions/functions/index.js new file mode 100644 index 00000000..7b93e4f2 --- /dev/null +++ b/stml_functions/functions/index.js @@ -0,0 +1,53 @@ +/** + * Import function triggers from their respective submodules: + * + * const {onCall} = require("firebase-functions/v2/https"); + * const {onDocumentWritten} = require("firebase-functions/v2/firestore"); + * + * See a full list of supported triggers at https://firebase.google.com/docs/functions + */ + +// const {onRequest} = require("firebase-functions/v2/https"); +// const logger = require("firebase-functions/logger"); + +// Create and deploy your first functions +// https://firebase.google.com/docs/functions/get-started + +// exports.helloWorld = onRequest((request, response) => { +// logger.info("Hello logs!", {structuredData: true}); +// response.send("Hello from Firebase!"); +// }); + + +const functions = require("firebase-functions"); +const admin = require("firebase-admin"); + +// Initialize Firebase Admin SDK +admin.initializeApp(); + +// Cloud Function to send notifications to a topic +exports.sendNotification = functions.https.onRequest((req, res) => { + // Extract topic and message from the request body + const topic = req.body.topic; + const message = req.body.message; + + // Construct the notification payload + const payload = { + notification: { + title: req.body.title, + body: message, + }, + topic: topic, + }; + + // Send the message to the topic using Firebase Admin SDK + admin.messaging().send(payload) + .then((response) => { + console.log("Notification sent successfully:", response); + res.status(200).send("Notification sent successfully!"); + }) + .catch((error) => { + console.error("Error sending notification:", error); + res.status(500).send("Error sending notification"); + }); +}); From 3dfd98fb4dae4c0eb984d624bd47f873c8d41b0c Mon Sep 17 00:00:00 2001 From: SECAP-670 Date: Mon, 31 Mar 2025 18:09:30 -0400 Subject: [PATCH 2/2] Firebase functions --- STML/stml_application/lib/src/features/help/help_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STML/stml_application/lib/src/features/help/help_screen.dart b/STML/stml_application/lib/src/features/help/help_screen.dart index af0e5e88..26317318 100644 --- a/STML/stml_application/lib/src/features/help/help_screen.dart +++ b/STML/stml_application/lib/src/features/help/help_screen.dart @@ -49,7 +49,7 @@ class _HelpScreenState extends State { // Replace with your country's emergency number, e.g., "112" or "911" final status = await Permission.phone.request(); print(status); - final Uri launchUri = Uri(scheme: 'tel', path: '411'); + final Uri launchUri = Uri(scheme: 'tel', path: ''); if (await canLaunchUrl(launchUri)) { await launchUrl(launchUri); } else {