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-01-20 18:27:31 +08:00
|
|
|
|
2013-10-18 11:14:33 +08:00
|
|
|
};
|
2014-01-20 18:27:31 +08:00
|
|
|
JPushPlugin.prototype.call_native = function ( name, args) {
|
2014-06-04 13:20:24 +08:00
|
|
|
|
2014-01-20 18:27:31 +08:00
|
|
|
ret = cordova.exec(null,
|
|
|
|
null,
|
|
|
|
'JPushPlugin',
|
|
|
|
name,
|
|
|
|
args);
|
|
|
|
return ret;
|
|
|
|
}
|
2014-06-05 16:36:54 +08:00
|
|
|
JPushPlugin.prototype.getRegistrationID = function () {
|
|
|
|
|
|
|
|
this.call_native( "getRegistrationID", null);
|
|
|
|
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.startLogPageView = function (data) {
|
|
|
|
if (data==null || typeof(data)=="undefined" || data==""){
|
|
|
|
console.log("argument is null");
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.call_native( "startLogPageView", [data]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.stopLogPageView = function (data) {
|
|
|
|
if (data==null || typeof(data)=="undefined" || data==""){
|
|
|
|
console.log("argument is null");
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.call_native( "stopLogPageView", [data]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.initNotificationCenter = function () {
|
|
|
|
|
|
|
|
this.call_native( "initNotifacationCenter", null);
|
|
|
|
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.parseEvent = function (data) {
|
|
|
|
try{
|
|
|
|
var parament=""
|
|
|
|
var count=1;
|
|
|
|
var start=false;
|
|
|
|
for(var i in data){
|
|
|
|
|
|
|
|
if(data[i]=='['){
|
|
|
|
if (count==1&&start==false) {
|
|
|
|
start=true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
if (data[i]==']') {
|
|
|
|
if(count==1)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
parament+=data[i]
|
|
|
|
|
|
|
|
}
|
|
|
|
return parament;
|
|
|
|
}
|
|
|
|
catch(exception){
|
|
|
|
alert(exception);
|
|
|
|
}
|
|
|
|
}
|
2014-06-04 13:20:24 +08:00
|
|
|
|
2014-01-20 18:27:31 +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);
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.setTags = function (data) {
|
|
|
|
|
|
|
|
try{
|
|
|
|
this.call_native("setTags", [data]);
|
|
|
|
}
|
|
|
|
catch(exception){
|
2014-06-06 18:15:08 +08:00
|
|
|
console.log(exception);
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
JPushPlugin.prototype.setAlias = function (data) {
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
this.call_native("setAlias", [data]);
|
|
|
|
}
|
|
|
|
catch(exception){
|
|
|
|
|
2014-06-06 18:15:08 +08:00
|
|
|
console.log(exception);
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
2013-10-18 11:14:33 +08:00
|
|
|
}
|
|
|
|
JPushPlugin.prototype.pushCallback = function (data) {
|
2014-01-20 18:27:31 +08:00
|
|
|
try{
|
|
|
|
var bToObj=JSON.parse(data);
|
|
|
|
var code = bToObj.resultCode;
|
|
|
|
var tags = bToObj.resultTags;
|
|
|
|
var alias = bToObj.resultAlias;
|
2014-06-05 16:36:54 +08:00
|
|
|
console.log("JPushPlugin:callBack--code is "+code+" tags is "+tags + " alias is "+alias);
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
|
|
|
catch(exception){
|
2014-06-05 16:36:54 +08:00
|
|
|
|
2014-06-06 18:15:08 +08:00
|
|
|
console.log(exception);
|
2014-01-20 18:27:31 +08:00
|
|
|
}
|
2013-10-21 11:28:42 +08:00
|
|
|
}
|
2014-06-05 16:36:54 +08:00
|
|
|
JPushPlugin.prototype.registrationCallback = function (data) {
|
|
|
|
try{
|
|
|
|
console.log("registrationCallback--registraionID is "+data);
|
|
|
|
}
|
|
|
|
catch(exception){
|
2014-06-06 18:15:08 +08:00
|
|
|
console.log(exception);
|
2014-06-05 16:36:54 +08:00
|
|
|
}
|
|
|
|
}
|
2013-10-18 11:14:33 +08:00
|
|
|
if(!window.plugins) {
|
2014-01-20 18:27:31 +08:00
|
|
|
window.plugins = {};
|
2013-10-18 11:14:33 +08:00
|
|
|
}
|
|
|
|
if(!window.plugins.jPushPlugin){
|
2014-01-20 18:27:31 +08:00
|
|
|
window.plugins.jPushPlugin = new JPushPlugin();
|
|
|
|
}
|
|
|
|
module.exports = new JPushPlugin();
|
2014-06-05 16:36:54 +08:00
|
|
|
|
|
|
|
});
|