Commit 93551a29 by 朱建香

获取cid方法

parent 8a7a6d43
/**
* @class
* unotify
*/
class unotify{
static async getCid(successCallback, errorCallback){
var a = null;
try{
a = await this.getCidPeriotic(3);
if(typeof successCallback == 'function'){
successCallback(a);
}
}
catch (err){
console.log(err);
if(typeof errorCallback == 'function'){
errorCallback(a);
}
}
}
static getCidPeriotic(times){
var self = this;
return new Promise(function(resolve, reject){
var i = 0;
var cid = null;
var handle = null;
i++;
cid = self.getCidOnce(i);
if(cid != null || i >= times){
window.clearInterval(handle);
resolve(cid);
}else{
handle = setInterval(function(){
i++;
cid = self.getCidOnce(i);
if(cid != null || i >= times){
window.clearInterval(handle);
resolve(cid);
}
},1000);
}
});
}
static getCidOnce(i){
var clientInfo = plus.push.getClientInfo();
if(clientInfo && clientInfo.hasOwnProperty('clientid') && clientInfo.clientid){
return(clientInfo.clientid);
}else{
return(null);
}
}
}
export default unotify;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment