2017-02-14 3 views
0

Ich bin auf der Suche nach einer Benachrichtigung von einem Nodejs-Server senden, aber ich bekomme einige Fehler, die ich nicht weiß, wie es zu lösen. Könnte mir jemand helfen? Ich fand diese mögliche Lösung auf Internet ->URLFcm Benachrichtigungen Push android/IOS nodejs

Dies ist mein Code in NodeJS

var FCM = require('fcm-push'); 

function sendNotification(){ 

var serverKey = 'AAAAJnK3Ing:AP-(more caracters)AwAlBL_CvXIkFM2UufYZHYkvhC7FP3Tu16mlI'; 
var fcm = new FCM(serverKey); 

var message = { 
    to: 'd2b2v(more caracters token)DUmAXqU-uHptJJLRPXukl', 
    /*data: { 
     your_custom_data_key: 'your_custom_data_value' 
    },*/ 
    notification: { 
     title: 'notification', 
     body: 'This is a notification from node' 
    } 
}; 

//callback style 
fcm.send(message, function(err, response){ 
    if (err) { 
     console.log("****************************************************") 
     console.log(message) 
     console.log("Something has gone wrong!"); 
    } else { 
     console.log("Successfully sent with response: ", response); 
    } 
}); 

//promise style 
fcm.send(message) 
    .then(function(response){ 
     console.log("Successfully sent with response: ", response); 
    }) 
    .catch(function(err){ 
     console.log("----------------------------------------------------") 
     console.log("Something has gone wrong!"); 
     console.error(err); 
    }) 

} 

module.exports = { 
    sendNotification 
} 

I am getting this error

Antwort

0

Versuchen zu überprüfen, ob Ihre Firewall auf Port 443 verbinden lassen. Es scheint, als könnte die Verbindung nicht hergestellt werden.

+0

Ja, es ist offen und zuhören –

Verwandte Themen