-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
29 lines (21 loc) · 875 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const functions = require("firebase-functions");
const admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Loyd Firebase!");
});
exports.sendMessage = functions.https.onRequest(async (request, response) => {
await admin.messaging().sendMulticast({
tokens: ["Your_FCM_Token_One", "Your_FCM_Token_Two"],
notification: {
title: "Hello Loyd!",
body: "This message is from Cloud Function",
imageUrl: "https://yt3.ggpht.com/ytc/AAUvwnjuH8xEOYQyRAE2NMrVieRw0GBbcJ9l5wLPpvgHDQ=s88-c-k-c0x00ffffff-no-rj",
},
});
response.json({result: "Sending message done"});
});