Skip to content

Instantly share code, notes, and snippets.

@malibayram
Last active September 30, 2020 15:27
Show Gist options
  • Select an option

  • Save malibayram/f800c49cdc3179170cfdc77ff5b3af62 to your computer and use it in GitHub Desktop.

Select an option

Save malibayram/f800c49cdc3179170cfdc77ff5b3af62 to your computer and use it in GitHub Desktop.
her yeni eklenen duyuru için "tumDuyurular" konusuna abone olmuş kişilere bildirim gönderme
const { fcm } = require('../admin');
const functions = require('firebase-functions');
const duyuruBidirimiGonder = functions.firestore.document('duyurular/{baslik}').onCreate(async (veri) => {
const baslik = veri.data().baslik;
const mesaj = veri.data().mesaj;
const tarih = veri.data().tarih;
const yayinlayan = veri.data().yayinlayan;
const bildirim = {
notification: {
title: baslik,
body: mesaj,
click_action: "SENV2_NOTIFICATION_CLICK",
sound: "default",
},
data: {
"tip": "duyuru",
"tarih": `${tarih}`,
"yayinlayan": `${yayinlayan}`,
"routeName": "/son_bildirimler",
}
}
return await fcm.sendToTopic("tumDuyurular", bildirim);
});
module.exports = duyuruBidirimiGonder;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment