Receive GCM push notification in node.js app

后端 未结 5 1379
慢半拍i
慢半拍i 2021-01-02 12:22

I\'m building a command-line application in node.js and would like to receive GCM push notifications (the command-line app will be interacting with the same set of services

5条回答
  •  时光取名叫无心
    2021-01-02 13:02

    i think if you have to send push notification ,to ios and andriod then fcm is better then gcm use this

    router.post('/pushmessage', function (req, res) {
        var serverKey = '';//put server key here
        var fcm = new FCM(serverKey);
        var token = "";// put token here which user you have to send push notification
        var message = {
            to: token,
            collapse_key: 'your_collapse_key',
            notification: {title: 'hello', body: 'test'},
            data: {my_key: 'my value', contents: "abcv/"}
        };
        fcm.send(message, function (err, response) {
            if (err) {
                res.json({status: 0, message: err});
            } else {
                res.json({status: 1, message: response});
            }
        });
    });
    

提交回复
热议问题