私はpush.jsを使用してPushNotificationサーバを構築しようとしています。 私は "node-fcm"を使用しましたが、私とはうまく動作しませんので、 "node-gcm"しかし私は同じ問題に直面した、私はすべてのユーザーのための通知を送信する方法を知らない?私がフィールドに書く必要があるもの(to :)?node-gcm:すべてのデバイスにPushNotificationを送信する
これは私のコードです:
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');
});
結果は次のとおりです。
{ 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
注:私はイオン2使用して、私はhttps://console.firebase.google.com/からnotifcationを受け取ることができます。