getui-rest-sdk
个推的nodejs sdk实在是太难用了……功能要啥啥没有,于是只好用rest-api重新封一遍
接口参数参考
http://docs.getui.com/server/rest/push/
Classes
-
Getui ⇐
EventEmitter
-
个推RestAPI SDK
Typedefs
-
Message :
object
-
Notification :
object
-
Condition :
object
-
APNsInfo :
object
EventEmitter
Getui ⇐ 个推RestAPI SDK
Kind: global class
Extends: EventEmitter
-
Getui ⇐
EventEmitter
- new Getui(appId, appKey, masterSecret, [interval])
-
.waitAuth() ⇒
Promise
-
.auth() ⇒
Promise.<void>
-
.unauth() ⇒
Promise.<void>
-
.pushSingle(message, template, cid, [apnsInfo], [requestId]) ⇒
Promise.<object>
-
.pushSingleAlias(message, template, alias, [apnsInfo], [requestId]) ⇒
Promise.<object>
-
.saveListBody(message, template, [apnsInfo], [taskName]) ⇒
Promise
-
.toList(cidList, taskId, [needDetail]) ⇒
Promise
-
.toListAlias(aliasList, taskId, [needDetail]) ⇒
Promise
-
.pushApp(message, template, [apnsInfo], [condition], [requestId]) ⇒
Promise
-
.stopTask(taskId) ⇒
Promise
-
.pushSingleBatch(msgList) ⇒
Promise
-
.bindAlias(aliasList) ⇒
Promise
-
.queryCid(alias) ⇒
Promise
-
.queryAlias(cid) ⇒
Promise
-
.unbindAlias(cid, alias) ⇒
Promise
-
.unbindAliasAll(alias) ⇒
Promise
-
.setTags(cid, tagList) ⇒
Promise
-
.getTags(cid) ⇒
Promise
-
.userBlkListAdd(cid) ⇒
Promise
-
.userBlkListDelete(cid) ⇒
Promise
-
.userStatus(cid) ⇒
Promise
-
.pushResult(taskIdList) ⇒
Promise
-
.queryAppUser(date) ⇒
Promise
-
.queryAppPush(date) ⇒
Promise
-
.setBadge(badge, cids) ⇒
Promise
-
.getPushResultByGroupName(groupName) ⇒
Promise
-
.getLast24HoursOnlineUsreStatistics() ⇒
Promise
-
.queryUserCount(condition) ⇒
Promise
-
.queryBiTags() ⇒
Promise
-
.getFeedbackUsers(taskId, cids) ⇒
Promise
- "ready"
- "refresh-token"
new Getui(appId, appKey, masterSecret, [interval])
初始化个推RestAPI
Param | Type | Default | Description |
---|---|---|---|
appId | string |
||
appKey | string |
||
masterSecret | string |
||
[interval] |
string | boolean
|
"23h" |
自动token续期,false禁用 |
Promise
getui.waitAuth() ⇒ 等待认证完成
Kind: instance method of Getui
Promise.<void>
getui.auth() ⇒ 认证,token有效期24小时
Kind: instance method of Getui
Throws:
-
Error
auth failed
Emits: ready
Promise.<void>
getui.unauth() ⇒ 关闭鉴权
Kind: instance method of Getui
Promise.<object>
getui.pushSingle(message, template, cid, [apnsInfo], [requestId]) ⇒ 单推
Kind: instance method of Getui
Returns: Promise.<object>
- 接口返回的json
Param | Type | Description |
---|---|---|
message | Message |
|
template |
Notification | null
|
|
cid | string |
cid |
[apnsInfo] | APNsInfo |
apns的json,ios需要 |
[requestId] | string |
requestId |
Promise.<object>
getui.pushSingleAlias(message, template, alias, [apnsInfo], [requestId]) ⇒ 单推给alias
Kind: instance method of Getui
Returns: Promise.<object>
- 接口返回的json
Param | Type | Description |
---|---|---|
message | Message |
|
template |
Notification | null
|
|
alias | string |
alias |
[apnsInfo] | APNsInfo |
apns的json,ios需要 |
[requestId] | string |
requestId |
Promise
getui.saveListBody(message, template, [apnsInfo], [taskName]) ⇒ 保存消息共同体
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
message | Message |
|
template |
Notification | null
|
|
[apnsInfo] | APNsInfo |
apns的json,ios需要 |
[taskName] | string |
任务名称 |
Promise
getui.toList(cidList, taskId, [needDetail]) ⇒ 群推
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
cidList | array |
cidList |
taskId | string |
保存消息共同体的返回结果 |
[needDetail] | boolean |
默认值:false,是否需要返回每个CID的状态 |
Promise
getui.toListAlias(aliasList, taskId, [needDetail]) ⇒ 群推alias
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
aliasList | array |
alias |
taskId | string |
保存消息共同体的返回结果 |
[needDetail] | boolean |
默认值:false,是否需要返回每个CID的状态 |
Promise
getui.pushApp(message, template, [apnsInfo], [condition], [requestId]) ⇒ toapp群推
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
message | Message |
|
template |
Notification | null
|
|
[apnsInfo] | APNsInfo |
|
[condition] | Condition |
筛选目标用户条件 |
[requestId] | string |
Promise
getui.stopTask(taskId) ⇒ 停止群推任务
Kind: instance method of Getui
Param | Type |
---|---|
taskId | string |
Promise
getui.pushSingleBatch(msgList) ⇒ 批量单推
Kind: instance method of Getui
Param | Type |
---|---|
msgList | array.<object> |
Promise
getui.bindAlias(aliasList) ⇒ 绑定别名
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
aliasList | array.<object> |
|
aliasList[].cid | string |
cid |
aliasList[].alias | string |
别名 |
Promise
getui.queryCid(alias) ⇒ 别名查询
Kind: instance method of Getui
Param | Type |
---|---|
alias | string |
Promise
getui.queryAlias(cid) ⇒ 根据cid查询别名
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
Promise
getui.unbindAlias(cid, alias) ⇒ 单个cid和别名解绑
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
alias | string |
Promise
getui.unbindAliasAll(alias) ⇒ 解绑别名所有cid
Kind: instance method of Getui
Param | Type |
---|---|
alias | string |
Promise
getui.setTags(cid, tagList) ⇒ 设置tag
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
tagList | array.<string> |
Promise
getui.getTags(cid) ⇒ 获取cid的tag
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
Promise
getui.userBlkListAdd(cid) ⇒ 添加用户黑名单
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
Promise
getui.userBlkListDelete(cid) ⇒ 删除用户黑名单
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
Promise
getui.userStatus(cid) ⇒ 查询用户状态
Kind: instance method of Getui
Param | Type |
---|---|
cid | string |
Promise
getui.pushResult(taskIdList) ⇒ 获取推送结果
Kind: instance method of Getui
Param | Type |
---|---|
taskIdList | array.<string> |
Promise
getui.queryAppUser(date) ⇒ 获取单日用户数据
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
date | string |
yyyymmdd 20170823 |
Promise
getui.queryAppPush(date) ⇒ 获取单日推送数据
Kind: instance method of Getui
Param | Type | Description |
---|---|---|
date | string |
yyyymmdd 20170823 |
Promise
getui.setBadge(badge, cids) ⇒ 应用角标设置接口(仅iOS)
Kind: instance method of Getui
Param | Type |
---|---|
badge | number |
cids | array.<string> |
Promise
getui.getPushResultByGroupName(groupName) ⇒ 根据任务组名获取推送结果
Kind: instance method of Getui
Param | Type |
---|---|
groupName | string |
Promise
getui.getLast24HoursOnlineUsreStatistics() ⇒ 获取24小时在线用户数
Kind: instance method of Getui
Promise
getui.queryUserCount(condition) ⇒ 按条件查询用户数
Kind: instance method of Getui
Param | Type |
---|---|
condition | Condition |
Promise
getui.queryBiTags() ⇒ 获取可用bi标签
Kind: instance method of Getui
Promise
getui.getFeedbackUsers(taskId, cids) ⇒ 获取回执的用户列表
Kind: instance method of Getui
Param | Type |
---|---|
taskId | string |
cids | string |
"ready"
认证完成,准备就绪
Kind: event emitted by Getui
"refresh-token"
重新获取了token
Kind: event emitted by Getui
object
Message : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
is_offline | boolean |
是否存为离线消息 |
offline_expire_time | number |
离线时间 |
push_network_type | number |
选择推送消息使用网络类型,0:不限制,1:wifi |
msgtype | string |
消息应用类型,可选项:notification、link、notypopload、transmission |
object
Notification : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
style | object |
样式 |
style.type | number |
样式类型,0-原生,1-个推样式,4-纯图,6-展开通知 |
style.text | string |
text |
style.title | string |
title |
style.logo | string |
logo |
style.logourl | string |
logoUrl |
style.is_ring} | boolean |
是否响铃 |
style.is_vibrate} | boolean |
是否震动 |
style.is_clearable} | boolean |
是否可清除 |
duration_begin | string |
设定展示开始时间,格式为yyyy-MM-dd HH:mm:ss |
duration_end | string |
设定展示结束时间,格式为yyyy-MM-dd HH:mm:ss |
transmission_type | boolean |
是否透传 |
transmission_content | string |
透传内容 |
object
Condition : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
key | string |
筛选条件类型名称(省市region,手机类型phonetype,用户标签tag) |
values | string |
筛选参数 |
opt_type | string |
筛选参数的组合,0:取参数并集or,1:交集and,2:相当与not in {参数1,参数2,....} |
object
APNsInfo : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
aps | object |
apple push service |
aps.alert | object |
消息 |
aps.alert.body | string |
通知文本消息 |
aps.alert.action-loc-key | string |
(用于多语言支持)指定执行按钮所使用的Localizable.strings |
aps.alert.loc-key | string |
(用于多语言支持)指定Localizable.strings文件中相应的key |
aps.alert.loc-args | Array.<string> |
如果loc-key中使用了占位符,则在loc-args中指定各参数 |
aps.alert.launch-image | string |
指定启动界面图片名 |
aps.alert.title | string |
通知标题 |
aps.alert.titile-loc-key | string |
(用于多语言支持)对于标题指定执行按钮所使用的Localizable.strings,仅支持iOS8.2以上版本 |
aps.alert.title-loc-args | Array.<string> |
对于标题,如果loc-key中使用的占位符,则在loc-args中指定各参数,仅支持iOS8.2以上版本 |
aps.alert.subtitle | string |
通知子标题,仅支持iOS8.2以上版本 |
aps.alert.subtitle-loc-key | string |
当前本地化文件中的子标题字符串的关键字,仅支持iOS8.2以上版本 |
aps.alert.subtitle-loc-args | string |
当前本地化子标题内容中需要置换的变量参数 ,仅支持iOS8.2以上版本 |
aps.autoBadge | string |
用于计算icon上显示的数字,还可以实现显示数字的自动增减,如“+1”、 “-1”、 “1” 等,计算结果将覆盖badge |
aps.sound | string |
通知铃声文件名,无声设置为“com.gexin.ios.silence” |
aps.content-available | number |
推送直接带有透传数据 |
aps.category | string |
在客户端通知栏触发特定的action和button显示 |
multimedia | Array.<object> |
多媒体 |
multimedia[].url | string |
多媒体资源地址 |
multimedia[].type | number |
资源类型(1.图片,2.音频, 3.视频) |
multimedia[].only_wifi | boolean |
是否只在wifi环境下加载,如果设置成true,但未使用wifi时,会展示成普通通知 |