2014-06-05 16:36:54 +08:00
|
|
|
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
|
2013-10-18 11:14:33 +08:00
|
|
|
var JPushPlugin = function(){
|
|
|
|
};
|
2014-06-05 16:36:54 +08:00
|
|
|
|
2014-06-10 14:54:17 +08:00
|
|
|
JPushPlugin.prototype.isPlatformIOS = function(){
|
|
|
|
return device.platform == "iPhone" || device.platform == "iPad" || device.platform == "iPod touch" || device.platform == "iOS"
|
|
|
|
}
|
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.error_callback = function(msg){
|
|
|
|
console.log("Javascript Callback Error: " + msg)
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.call_native = function(name, args, callback){
|
|
|
|
ret = cordova.exec(callback,this.error_callback,'JPushPlugin',name,args);
|
|
|
|
return ret;
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.getRegistrationID = function(callback){
|
|
|
|
this.call_native("getRegistrationID",null,callback);
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.startLogPageView = function(data){
|
|
|
|
this.call_native( "startLogPageView",[data],null);
|
|
|
|
}
|
2014-06-05 16:36:54 +08:00
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.stopLogPageView = function(data){
|
|
|
|
this.call_native( "stopLogPageView",[data],null);
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
2014-06-04 13:20:24 +08:00
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
JPushPlugin.prototype.setTagsWithAlias = function(tags,alias){
|
|
|
|
if(tags==null){
|
|
|
|
this.setAlias(alias);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(alias==null){
|
|
|
|
this.setTags(tags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var arrayTagWithAlias=[tags];
|
|
|
|
arrayTagWithAlias.unshift(alias);
|
|
|
|
this.call_native( "setTagsWithAlias", arrayTagWithAlias,null);
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
|
|
|
|
JPushPlugin.prototype.setTags = function(data){
|
2014-01-20 18:27:31 +08:00
|
|
|
|
2014-06-10 14:14:02 +08:00
|
|
|
try{
|
|
|
|
this.call_native("setTags",[data],null);
|
|
|
|
}
|
|
|
|
catch(exception){
|
|
|
|
console.log(exception);
|
|
|
|
}
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
|
|
|
|
JPushPlugin.prototype.setAlias = function(data){
|
|
|
|
try{
|
|
|
|
this.call_native("setAlias", [data],null);
|
|
|
|
}
|
|
|
|
catch(exception){
|
|
|
|
console.log(exception);
|
|
|
|
}
|
2013-10-18 11:14:33 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
|
|
|
|
JPushPlugin.prototype.pushCallback = function(data){
|
|
|
|
try{
|
|
|
|
var bToObj=JSON.parse(data);
|
|
|
|
var code = bToObj.resultCode;
|
|
|
|
var tags = bToObj.resultTags;
|
|
|
|
var alias = bToObj.resultAlias;
|
|
|
|
console.log("JPushPlugin:callBack--code is "+code+" tags is "+tags + " alias is "+alias);
|
|
|
|
}
|
|
|
|
catch(exception){
|
|
|
|
console.log(exception);
|
|
|
|
}
|
2013-10-21 11:28:42 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
//android
|
|
|
|
//ios
|
|
|
|
|
|
|
|
JPushPlugin.prototype.initNotificationCenter = function(){
|
|
|
|
this.call_native( "initNotifacationCenter", null,null);
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
|
|
|
|
if(!window.plugins){
|
|
|
|
window.plugins = {};
|
2013-10-18 11:14:33 +08:00
|
|
|
}
|
2014-06-10 14:14:02 +08:00
|
|
|
|
2013-10-18 11:14:33 +08:00
|
|
|
if(!window.plugins.jPushPlugin){
|
2014-06-10 14:14:02 +08:00
|
|
|
window.plugins.jPushPlugin = new JPushPlugin();
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new JPushPlugin();
|
|
|
|
|
2014-06-05 16:36:54 +08:00
|
|
|
});
|