2017-07-25 14:33:06 +00:00
|
|
|
var messages = require('./gorush_pb');
|
|
|
|
var services = require('./gorush_grpc_pb');
|
|
|
|
|
|
|
|
var grpc = require('grpc');
|
|
|
|
|
|
|
|
function main() {
|
2017-10-19 01:24:47 +00:00
|
|
|
var client = new services.GorushClient('localhost:9000',
|
2017-07-25 14:33:06 +00:00
|
|
|
grpc.credentials.createInsecure());
|
|
|
|
var request = new messages.NotificationRequest();
|
2018-01-03 09:08:28 +00:00
|
|
|
var alert = new messages.Alert();
|
2017-07-25 14:33:06 +00:00
|
|
|
request.setPlatform(2);
|
|
|
|
request.setTokensList(["1234567890"]);
|
|
|
|
request.setMessage("Hello!!");
|
2018-01-03 09:08:28 +00:00
|
|
|
request.setTitle("hello2");
|
|
|
|
request.setBadge(2);
|
|
|
|
request.setCategory("mycategory");
|
2018-01-04 03:31:03 +00:00
|
|
|
request.setSound("sound")
|
2018-01-03 09:08:28 +00:00
|
|
|
alert.setTitle("title");
|
|
|
|
request.setAlert(alert);
|
2018-01-10 01:36:27 +00:00
|
|
|
request.setThreadid("threadID");
|
|
|
|
request.setContentavailable(false);
|
2017-07-25 14:33:06 +00:00
|
|
|
client.send(request, function (err, response) {
|
2018-01-03 09:08:28 +00:00
|
|
|
if(err) {
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
console.log("Success:", response.getSuccess());
|
|
|
|
console.log("Counts:", response.getCounts());
|
|
|
|
}
|
2017-07-25 14:33:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|