- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/xialeistudio/bpush-nodejs
- 软件文档: https://github.com/xialeistudio/bpush-nodejs#readme
软件介绍
bpush-nodejs 是百度云推送 nodejs sdk,使用简单,部署方便,基于百度云推送 rest api 3.0开发。
使用
npm install bpush-nodejs --save
var bpush = require('bpush-nodejs');
...说明
SDK采用Promise方式进行回调,demo代码如下(以推送单个设备为例),catch代码块中 只捕获HTTP请求错误,如果HTTP请求成功,但是百度服务端报错,请自行在then中处理
var data = {
channel_id: '5247517738736986629',
msg: JSON.stringify({
aps: {
alert: '你是呵呵SINGLE'
}
}),
msg_type: bpush.constant.MSG_TYPE.NOTIFICATION,
deploy_status: bpush.constant.DEPLOY_STATUS.DEVELOPMENT,
device_type: bpush.constant.DEVICE_TYPE.IOS
};
bpush.sendRequest(bpush.apis.pushMsgToSingleDevice, data).then(function (data) {
data = JSON.parse(data);
console.log(data);
}).catch(function(e){
console.error(e);
});所有api调用方法均为 bpush.sendRequest(bpush.apis.[api名称], [api需要的数据])。
