node.js - 在 node.js 应用程序中接收 GCM 推送通知

标签 node.js google-cloud-messaging

我正在 node.js 中构建命令行应用程序并希望接收 GCM 推送通知(命令行应用程序将与 iOS/Android 应用程序使用的同一组服务交互,因此想使用相同的通知服务)。

鉴于 GCM 可以在 iOS 上使用(因此不是特定于 Android 的)我希望它也可以在 node.js 上使用。

我看过很多关于发送来自 node.js 的推送通知的文章,但还没有找到任何关于在接收端使用 node.js 的文章。

最佳答案

我认为如果你必须向 ios 和 android 发送推送通知,那么 fcm 比 fcm 使用这个更好

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});
        }
    });
});

关于node.js - 在 node.js 应用程序中接收 GCM 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41106557/

相关文章:

java - 使用无效注册 ID 时,GCM 返回 BAD 请求

php - 从mysql数据库一次向多个用户发送gcm

node.js - 通过 Node.JS 连接 RedisToGo

node.js - 带有 JWT 的 Facebook Passport

node.js - 仅没有范围的Nodejs DynamoDB CreateTable哈希返回ValidationException

Node.js sendgrid 实现

android - 来自现有 GCM 项目的 GCM API key ?

node.js - npm 本地依赖太多?

android - GCM 和 SIM 的变化

iOS Swift GCM/FCM 在后台接收通知