0.0.4 • Published 7 years ago
sun-getui-sdk v0.0.4
getui sdk
lib为官方的原版目录 具体api需要参考官方 http://docs.getui.com/server/nodejs/start/
Install
npm install --save sun-getui-sdk
Examples
const getui = require('sun-getui-sdk')
const getuiConfig = {
"appId": "O6Yu3JHjV98ZskTkzcHhQ",
"appKey": "alhTZbRL7m9LW1aEXqsoP4",
"appSecret": "cKnTp73lQx6cKxkPjuOu48",
"masterSecret": "yRYxy2nNr3AU7t67QfqZLA",
"host": "https://api.getui.com/apiex.htm"
}
const getuiDemo = new getui.GeTui(getuiConfig.host, getuiConfig.appKey, getuiConfig.masterSecret)
const template = new getui.LinkTemplate({
appId: getuiConfig.appId,
appKey: getuiConfig.appKey,
title: '个推',
text: '个推最新版点击下载',
logoUrl: 'http://wwww.igetui.com/logo.png',
isRing: true,
isVibrate: true,
isClearable: false,
url: 'http://www.igetui.com'
});
const message = new getui.SingleMessage({
isOffline: true,
offlineExpireTime: '123123',
data: template
});
const target = new getui.Target({
appId: getuiConfig.appId,
clientId: '0b4cad197eaef79fd8225d236542fc8f'
});
getuiDemo.pushMessageToSingle(message, target)
.then(console.log)
.catch(console.error);
tip: 没有使用5+sdk就不用看下面代码了
// 针对在5+sdk使用了透传消息的,建议消息内容使用标准目标,才可以进入消息中心 但是ios在线的时候消息时不进入消息中心的,需要在页面监听receive事件
var template = new getui.TransmissionTemplate({
appId: getuiConfig.appId,
appKey: getuiConfig.appKey,
transmissionType: 1,
transmissionContent: "{\"title\":\"您有新的通知\",\"content\":\"请查阅:XXX批发公司已经审核了您的订单!\",\"payload\":{\"type\":1,\"refnumber\" :\"1000263\" ,\"total_count\":5}}"
});