I am trying to build PushNotification sever using node.js, I used "node-fcm" but it is not work with me, so i tryed to use "node-gcm", but I faced same problem, I don't know how to send notifcation for all users? what I need to write in fild (to:)??
this is my 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:password@my_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');
});`
the result is:
{ 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
note: i use Ionic 2 and i can recive notifcation from https://console.firebase.google.com/ .
via ajd.nas
No comments:
Post a Comment