delete notifacation center

This commit is contained in:
zhangqinhghe
2014-06-10 14:14:02 +08:00
parent f2918e7d9c
commit 60eefc2b5b
4 changed files with 161 additions and 284 deletions
+71 -122
View File
@@ -1,139 +1,88 @@
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
var JPushPlugin = function(){
};
JPushPlugin.prototype.call_native = function ( name, args) {
ret = cordova.exec(null,
null,
'JPushPlugin',
name,
args);
return ret;
}
JPushPlugin.prototype.getRegistrationID = function () {
this.call_native( "getRegistrationID", null);
JPushPlugin.prototype.error_callback = function(msg){
console.log("Javascript Callback Error: " + msg)
}
JPushPlugin.prototype.startLogPageView = function (data) {
if (data==null || typeof(data)=="undefined" || data==""){
console.log("argument is null");
JPushPlugin.prototype.call_native = function(name, args, callback){
ret = cordova.exec(callback,this.error_callback,'JPushPlugin',name,args);
return ret;
}
JPushPlugin.prototype.getRegistrationID = function(callback){
this.call_native("getRegistrationID",null,callback);
}
JPushPlugin.prototype.startLogPageView = function(data){
this.call_native( "startLogPageView",[data],null);
}
JPushPlugin.prototype.stopLogPageView = function(data){
this.call_native( "stopLogPageView",[data],null);
}
JPushPlugin.prototype.setTagsWithAlias = function(tags,alias){
if(tags==null){
this.setAlias(alias);
return;
}
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);
}
if(alias==null){
this.setTags(tags);
return;
}
var arrayTagWithAlias=[tags];
arrayTagWithAlias.unshift(alias);
this.call_native( "setTagsWithAlias", arrayTagWithAlias,null);
}
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) {
JPushPlugin.prototype.setTags = function(data){
try{
this.call_native("setTags", [data]);
}
catch(exception){
console.log(exception);
}
try{
this.call_native("setTags",[data],null);
}
catch(exception){
console.log(exception);
}
}
JPushPlugin.prototype.setAlias = function (data) {
try{
this.call_native("setAlias", [data]);
}
catch(exception){
console.log(exception);
}
JPushPlugin.prototype.setAlias = function(data){
try{
this.call_native("setAlias", [data],null);
}
catch(exception){
console.log(exception);
}
}
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);
}
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);
}
}
JPushPlugin.prototype.registrationCallback = function (data) {
try{
console.log("registrationCallback--registraionID is "+data);
}
catch(exception){
console.log(exception);
}
//android
//ios
JPushPlugin.prototype.initNotificationCenter = function(){
this.call_native( "initNotifacationCenter", null,null);
}
if(!window.plugins) {
window.plugins = {};
if(!window.plugins){
window.plugins = {};
}
if(!window.plugins.jPushPlugin){
window.plugins.jPushPlugin = new JPushPlugin();
}
module.exports = new JPushPlugin();
window.plugins.jPushPlugin = new JPushPlugin();
}
module.exports = new JPushPlugin();
});