说明
Node wrapper for getui OS SDK API 基于个推 nodejs sdk 4.0.1.0 进行 Promise 封装
api
使用 bluebird 对 GeTui 进行 Promise 封装
// http的域名 var HOST = 'http://sdk.open.api.igexin.com/apiex.htm'; //https的域名 // var HOST = 'https://api.getui.com/apiex.htm'; //Android用户测试 var APPID = ''; var APPKEY = ''; var MASTERSECRET = ''; var CID = ''; var gt = HOST APPKEY MASTERSECRET; // 使用Promise gt // 使用callback gt
快速开始
npm install getui-node-sdk
'use strict'; const // basic GeTui Target // template APNTemplate BaseTemplate NotyPopLoadTemplate LinkTemplate NotificationTemplate PopupTransmissionTemplate TransmissionTemplate // payload APNPayload DictionaryAlertMsg SimpleAlertMsg // message SingleMessage AppMessage ListMessage }=
'use strict';var getuiNodeSdk = ;var GeTui = getuiNodeSdkGeTui;var Target = getuiNodeSdkTarget;var APNTemplate = getuiNodeSdkAPNTemplate;var BaseTemplate = getuiNodeSdkBaseTemplate;var APNPayload = getuiNodeSdkAPNPayload;var DictionaryAlertMsg = getuiNodeSdkDictionaryAlertMsg;var SimpleAlertMsg = getuiNodeSdkSimpleAlertMsg;var NotyPopLoadTemplate = getuiNodeSdkNotyPopLoadTemplate;var LinkTemplate = getuiNodeSdkLinkTemplate;var NotificationTemplate = getuiNodeSdkNotificationTemplate;var PopupTransmissionTemplate = getuiNodeSdkPopupTransmissionTemplate;var TransmissionTemplate = getuiNodeSdkTransmissionTemplate; var SingleMessage = getuiNodeSdkSingleMessage;var AppMessage = getuiNodeSdkAppMessage;var ListMessage = getuiNodeSdkListMessage; // http的域名var HOST = 'http://sdk.open.api.igexin.com/apiex.htm'; //https的域名// var HOST = 'https://api.getui.com/apiex.htm'; //Android用户测试var APPID = '';var APPKEY = '';var MASTERSECRET = '';var CID = '';//IOS用户测试//var DEVICETOKEN='';var alias = 'demo'; var gt = HOST APPKEY MASTERSECRET;;;// pushMessageToSingleBatch();// pushMessageToList();// pushMessageToApp();// stoptask();// setClientTag();// getUserTags() //别名绑定操作// aliasBind();// queryCID();//queryAlias();//aliasBatch();//aliasUnBindAll();//aliasUnBind(); //结果查询操作// getPushResult();// queryAppPushDataByDate();// queryAppUserDataByDate(); //推送任务停止 { gt;} { // gt.setClientTag(APPID, CID, ['aa', '哔哔', '》?》', '!@#¥%……&*()'], function (err, res) { // console.log(err, res); // })} { gt} { gt;} { for var i = 0; i < 10; i++ var template = ; // var template = LinkTemplateDemo(); // var template = NotificationTemplateDemo(); // var template = NotyPopLoadTemplateDemo(); //个推信息体 var message = isOffline: true //是否离线 offlineExpireTime: 3600 * 12 * 1000 //离线时间 data: template //设置推送消息类型 pushNetWorkType: 0 //是否wifi ,0不限,1wifi ; //接收方 var target = appId: APPID clientId: CID ; gt; } { processenvgexin_pushSingleBatch_needAsync = true; var Batch = gt; var template = ; // var template = LinkTemplateDemo(); // var template = NotificationTemplateDemo(); // var template = NotyPopLoadTemplateDemo(); //个推信息体 var message = isOffline: true //是否离线 offlineExpireTime: 3600 * 12 * 1000 //离线时间 data: template //设置推送消息类型 ; //接收方 var target = appId: APPID clientId: CID // alias:'_lalala_' ; Batch; Batch; } { //process.env.gexin_pushList_needDetails = true; //process.env.gexin_pushList_needAsync=true; //process.env.=true; // var taskGroupName = 'test'; var taskGroupName = "toList任务组名"; var template = ; //个推信息体 var message = isOffline: true offlineExpireTime: 3600 * 12 * 1000 data: template ; gt;} { // var taskGroupName = 'test'; var taskGroupName = null; var template = ; //个推信息体 //基于应用消息体 var message = isOffline: false offlineExpireTime: 3600 * 12 * 1000 data: template appIdList: APPID // phoneTypeList: ['IOS'], // provinceList: ['浙江'], //tagList: ['阿百川'] speed: 10000 ; gt;} //消息模版:// 1.TransmissionTemplate:透传功能模板// 2.LinkTemplate:通知打开链接功能模板// 3.NotificationTemplate:通知透传功能模板// 4.NotyPopLoadTemplate:通知弹框下载功能模板 { var template = appId: APPID appKey: APPKEY notyTitle: '个推' notyContent: '个推最新版点击下载' notyIcon: 'http://wwww.igetui.com/logo.png' // 通知栏logo isRing: true isVibrate: true isClearable: true popTitle: '弹框标题' setPopContent: '弹框内容' popImage: '' popButton1: '下载' // 左键 popButton2: '取消' // 右键 loadIcon: 'http://www.photophoto.cn/m23/086/010/0860100017.jpg' // 弹框图片 loadUrl: 'http://dizhensubao.igexin.com/dl/com.ceic.apk' loadTitle: '地震速报下载' autoInstall: false actived: true ; return template;} { var template = appId: APPID appKey: APPKEY title: '个推' text: '个推最新版点击下载' logo: 'http://wwww.igetui.com/logo.png' logoUrl: 'https://www.baidu.com/img/bdlogo.png' isRing: true isVibrate: true isClearable: true url: 'http://www.igetui.com' ; return template;} { var template = appId: APPID appKey: APPKEY title: '个推' text: '个推最新版点击下载' // logo: 'http://www.igetui.com/logo.png', isRing: true isVibrate: true isClearable: true transmissionType: 1 transmissionContent: JSON ; return template;} { var template = appId: APPID appKey: APPKEY transmissionType: 2 transmissionContent: JSON ; //iOS推送需要设置的setApnInfo字段 // var payload = new APNPayload(); // var alertMsg = new DictionaryAlertMsg(); // alertMsg.body = ""; // alertMsg.actionLocKey = ""; // alertMsg.locKey = ""; // alertMsg.locArgs = Array(""); // alertMsg.launchImage = ""; // //ios8.2以上版本支持 // alertMsg.title = ""; // alertMsg.titleLocKey = ""; // alertMsg.titleLocArgs = Array(""); // //// payload.alertMsg=alertMsg; // payload.badge=5; //// payload.contentAvailable =1; //// payload.category=""; //// payload.sound=""; //// payload.customMsg.payload1="payload"; // template.setApnInfo(payload); // template.setDuration("2015-01-16 11:40:00", "2015-01-16 12:24:00"); return template;} { gt;} { // var target = new Target() // .setClientId(CID) // .setAlias('_lalala_'); var target2 = alias: alias clientId: CID ; var targetList = target2; gt;} { gt;} { gt;} { gt;} { gt;} { gt;} { gt;} { gt;}