UNPKG

jpush-async

Version:

JPush's officially supported Node.js client library.

32 lines (27 loc) 921 B
var JPush = require("../index.js").JPushAsync; var Conf = require("./Conf.js"); var client = JPush.buildClient(Conf.appKey, Conf.masterSecret); // 使用 proxy // var client = JPush.buildClient(Conf.appKey, Conf.masterSecret, null, null, null,'http://192.168.8.236:3128') // easy push. client.push().setPlatform(JPush.ALL) .setAudience(JPush.ALL) .setNotification('Hi, JPush', JPush.ios('ios alert', 'happy', 5)) .send() .then(function(result) { console.log(result) }).catch(function(err) { console.log(err) }) // full push. client.push().setPlatform('ios', 'android') .setAudience(JPush.tag('555', '666'), JPush.alias('666,777')) .setNotification('Hi, JPush', JPush.ios('ios alert'), JPush.android('android alert', null, 1)) .setMessage('msg content') .setOptions(null, 60) .send() .then(function(result) { console.log(result) }).catch(function(err) { console.log(err) })