MyGit

jpush/jpush-api-nodejs-client

Fork: 73 Star: 238 (更新于 2024-05-28 17:35:57)

license: GPL-2.0

Language: JavaScript .

JPush's officially supported Node.js client library for accessing JPush APIs. 极光推送官方支持的 Node.js 版本服务器端 SDK。

最后发布版本: v4.1.0 ( 2021-10-20 10:13:22)

官方网址 GitHub网址

JPush API client library for Node.js

本 SDK 提供 JPush 服务端接口的 Node 封装,与 JPush Rest API 组件通信。使用时引用该模块即可,可参考附带 Demo 学习使用方法。

Node >= 7.6(async/await 语法支持),若 node 版本小于 7.6 请使用 legacy 分支的代码

REST API 文档

NodeJS API 文档

Install

npm install jpush-async
#or
{
    "dependencies": {
        "jpush-async": "*"
    }
}

Example

Quick start

此 Demo 展示如何使用 Node lib 向所有用户推送通知。

var JPush = require("../lib/JPush/JPushAsync.js")
var client = JPush.buildClient('your appKey', 'your masterSecret')

//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)
    })

Expert mode(高级版)

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)
    });

关于 Payload 对象的方法,参考详细 API 文档

关闭 Log

// 在构建 JPushClient 对象的时候, 指定 isDebug 参数。
var client = JPush.buildClient({
    appKey:'your appKey',
    masterSecret:'your masterSecret',
    isDebug:false
});
// or
var client = JPush.buildClient('your appKey', 'your masterSecret', null, false);

目前使用了 debug 模块来控制日志输出,若要查看 JPush 的相关日志信息,请先配置 DEBUG 环境变量 'jpush'。

最近版本更新:(数据更新于 2024-05-13 09:10:48)

2021-10-20 10:13:22 v4.1.0

2021-10-19 10:51:42 v4.0.9

2021-10-19 10:20:58 v4.0.8

2021-08-03 17:03:16 v4.0.7

2021-08-02 14:41:27 v4.0.6

2019-11-27 16:52:09 v4.0.3

2018-06-05 10:32:44 v3.5.0

2018-03-20 16:13:15 v3.4.5

2018-03-05 10:52:59 v3.4.4

2017-10-18 16:59:18 v3.4.3

jpush/jpush-api-nodejs-client同语言 JavaScript最近更新仓库

2024-07-04 07:31:29 vercel/next.js

2024-06-25 20:14:46 projectdiscovery/nuclei-templates

2024-06-22 08:38:28 sveltejs/svelte

2024-06-20 17:48:22 4ian/GDevelop

2024-06-18 06:07:40 langflow-ai/langflow

2024-06-15 01:21:11 serverless/serverless