Firestore Firebase Cloud functions


I am generating an application in ionic with cloud firestore, I need to send a notification to the devices when I add a document to the news collection, I have been able to recover the Token from my emulator, and I have succeeded in sending a notification to the devices from Cloud Messaging, but I could not receive the notification from cloud functions, I'm new in this hopefully someone knows if I have omitted something

const functions = require('firebase-functions');

// // Create and Deploy Your First Cloud Functions
// //
// exports.helloWorld = functions.https.onRequest((request, response) => {
//  response.send("Hello from Firebase!");
// });
const admin = require('firebase-admin');

exports.newPopularPost = functions
    .onCreate((snapshot, context) => {
        var message = "There's a new popular post for you: " +;
        var payload = {
            notification: {
                title: 'New Popular Post!',
                body: message
            topic: 'popularPosts'
        return admin.messaging()
                    .send(payload, true) // Send the push in dry-run mode
                    .then(response => {
                        console.log('push success: ' + response);
                        return null;

I am using this code as proof

asked by Angel Adrian 28.11.2018 в 02:59

0 answers