appcan推送

学无止境✅  2015-12-27
0


window.uexOnload = function(type){
if (!type){
getpushtk();

}
}


//push
function getpushtk(){
uexDevice.cbGetInfo = function(opCode, dataType, data){
if(data !=""){
var obj = eval('('+data+')');
var tk=obj.deviceToken;
tk=tk.replace(/ /g,"");
pushios();
}
}
uexDevice.getInfo('11');//得到令牌
}

function pushios(){
uexWidget.setPushNotifyCallback("cbNotify");
setdeviceToken();
uexWidget.cbGetPushInfo = function(opCode, dataType, data){
pushopen(data);
}
uexWidget.getPushInfo();
}

function setdeviceToken(){
uexWidget.setPushInfo("appkunming.com","");
}

function cbNotify(){
uexWidget.getPushInfo();
}

function pushopen(str){
if(str.length==4 || str.length==6){return;}
//PUSH格式:{"type":"news","id":0}//type值为:news|prdouct ID值为要打开的内容ID
if(str.substring(0,1)!="{"){uexWindow.alert("推送详情:",str,"确定");return;}
var json=eval("["+str+"]");
if(json.length==1){
if(json[0].type=="news"){opennews(json[0].id,'news_top.html');return;}
if(json[0].type=="product"){opennews(json[0].id,'product_top.html');return;}
}
}

游客  现在