Ich versuche, PushNotification Server mit node.js, zu erstellen Ich habe "node-fcm" verwendet, aber es funktioniert nicht mit mir, so versuchte ich "node-gcm", aber ich hatte das gleiche Problem, ich weiß nicht, wie ich Benachrichtigungen an alle Benutzer senden soll. was ich im Feld schreiben muss (bis :) ??node-gcm: senden PushNotification für alle Geräte
dies ist mein Code:
var gcm = require('node-gcm');
var Sender_ID = '55*****';
var API_KEY = 'my server key';
var sender = new gcm.Sender(API_KEY,{'proxy':'http://username:[email protected]_proxyinternet.com:8080' , timeout: 5000});
var message = new gcm.Message({
notification: {
title: "Hello, World",
icon: "ic_launcher",
body: "This is a notification that will be displayed."
}
});
var registrationTokens = [];
registrationTokens.push(['All']);
sender.send(message, { registrationTokens: 'All' }, function (err, response) {
if (err) console.error(err + ' ERROR');
else console.log(response + ' ELSE');
});
das Ergebnis:
{ multicast_id: -1, success: 0, failure: 1, canonical_ids: 0, results: [ { error: 'InvalidRegistration' } ] } Error: Recipient key 'registrationTokens' was provided as an incorrect type. ERROR Process finished with exit code 0
Hinweis: Ich benutze Ionic 2 und ich kann Benachrichtigung von https://console.firebase.google.com/ erhalten.