javascript 通过node.js发送android推送通知
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13927744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending android push notification through node.js
提问by Amanda G
I have recently been trying to send push notification to my android and ios devices. For ios I found that node-apn module will be used for handling this,but for android I haven't come across anything of that sort. Any help will be much appreciated.
我最近一直在尝试向我的 android 和 ios 设备发送推送通知。对于 ios,我发现 node-apn 模块将用于处理此问题,但对于 android,我还没有遇到过这种情况。任何帮助都感激不尽。
回答by Muhammad Reda
There is another alternative; android-gcm. It is super easy to use.
还有另一种选择;安卓-gcm。它非常易于使用。
Code sample from documentation:
文档中的代码示例:
var gcm = require('android-gcm');
// initialize new androidGcm object
var gcmObject = new gcm.AndroidGcm('API_KEY');
// create new message
var message = new gcm.Message({
registration_ids: ['x', 'y', 'z'],
data: {
key1: 'key 1',
key2: 'key 2'
}
});
// send the message
gcmObject.send(message, function(err, response) {});