百度云推送 SDK bpush-nodejs

码农软件 · 软件分类 · 其他开发相关 · 2019-10-19 08:59:08

软件介绍

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需要的数据])

本文地址:https://codercto.com/soft/d/17080.html

Persuasive Technology

Persuasive Technology

B.J. Fogg / Morgan Kaufmann / 2002-12 / USD 39.95

Can computers change what you think and do? Can they motivate you to stop smoking, persuade you to buy insurance, or convince you to join the Army? "Yes, they can," says Dr. B.J. Fogg, directo......一起来看看 《Persuasive Technology》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具