push firebase notification

0

I hope you can help me, I have problems with push notification with firebase from nodeJS, doing local tests, when the page is not in the foreground if you show me the notification, the problem is when I pass the page to production, when I sent the notification since nodeJS does not appear to me

service worker code:

importScripts('https://www.gstatic.com/firebasejs/4.6.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.6.2/firebase-messaging.js');

var config = {
    apiKey: "mi_api_key",
    authDomain: "pushnotifications-3e193.firebaseapp.com",
    databaseURL: "https://pushnotifications-3e193.firebaseio.com",
    projectId: "pushnotifications-3e193",
    storageBucket: "pushnotifications-3e193.appspot.com",
    messagingSenderId: "256471388319"
};
firebase.initializeApp(config);

const messaging = firebase.messaging();

nodeJS code

    var payload = {
        notification: {
            title: "Actualizacion de contrato",
            body: "El contrato "+data.numero_cot+" sufrio un cambio",
            icon: "https://firebasestorage.googleapis.com/v0/b/pushnotifications-3e193.appspot.com/o/images%2Flogo_negro.png?alt=media&token=41619924-a5b1-4e78-97a9-dd42b15697ee",
            click_action: "https://gdlvan.com.mx/logistica/"
        }
    };
                                    admin.messaging().sendToDevice(registrationToken, payload, options).then(function(response) {
    console.log("Successfully sent message:", response);
}).catch(function(error) {
    console.log("Error sending message:", error);
});
    
asked by Valdo Ramos 16.04.2018 в 17:24
source

0 answers