This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const serviceAccount = require("./service-account.json"); | |
const { initializeApp, cert } = require('firebase-admin/app'); | |
const { getAuth } = require('firebase-admin/auth'); | |
const app = initializeApp({ | |
credential: cert(serviceAccount) | |
}) | |
const auth = getAuth(app) | |
exports.protectedEndpoint = functions.https.onRequest(async (request, response) => { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
const pushTokenDoc = await db.collection(`push_tokens/${userRef.id}`).doc(); | |
const token = pushTokenDoc.data().token; | |
const title = 'TITLE'; | |
const message = 'MESSAGE'; | |
const payload = { | |
notification: { | |
title: title, |
NewerOlder