mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 14:32:51 +08:00
delete notifacation center
This commit is contained in:
parent
f2918e7d9c
commit
60eefc2b5b
@ -5,61 +5,21 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<title>Phonegap Sample App</title>
|
<title>Phonegap Sample App</title>
|
||||||
|
|
||||||
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
|
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/jquery.js"></script>
|
<script type="text/javascript" src="js/jquery.js"></script>
|
||||||
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
|
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="cordova.js"></script>
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var onDeviceReady = function(){
|
||||||
var onDeviceReady = function() {
|
console.log("Device ready!")
|
||||||
console.log("Device ready!")
|
initiateUI();
|
||||||
initiateUI();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
var onTagsWithAlias = function(data) {
|
var onTagsWithAlias = function(event){
|
||||||
try{
|
try{
|
||||||
var tagaliasJson=window.plugins.jPushPlugin.parseEvent(data);
|
var result="result code:"+event.resultCode+" ";
|
||||||
$("#tagAliasResult").html(tagaliasJson);;
|
result+="tags:"+event.tags;
|
||||||
|
result+="alias"+event.alias;
|
||||||
}
|
$("#tagAliasResult").html(result);
|
||||||
catch(exception){
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var onDidSetup = function() {
|
|
||||||
try{
|
|
||||||
$("#connectState").html("建立连接");;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(exception){
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var onDidClose = function() {
|
|
||||||
try{
|
|
||||||
$("#connectState").html("连接关闭");;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(exception){
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var onDidRegister = function() {
|
|
||||||
try{
|
|
||||||
$("#connectState").html("注册成功");;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(exception){
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var onDidLogin = function() {
|
|
||||||
try{
|
|
||||||
$("#connectState").html("登录成功");;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(exception){
|
catch(exception){
|
||||||
console.log(exception)
|
console.log(exception)
|
||||||
@ -67,64 +27,45 @@
|
|||||||
}
|
}
|
||||||
var onGetRegistradionID = function(data) {
|
var onGetRegistradionID = function(data) {
|
||||||
try{
|
try{
|
||||||
var registrationID=window.plugins.jPushPlugin.parseEvent(data);
|
$("#registrationid").html(data);
|
||||||
$("#registrationid").html(registrationID);;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(exception){
|
catch(exception){
|
||||||
console.log(exception)
|
console.log(exception);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var initiateUI = function(){
|
||||||
var initiateUI = function() {
|
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
||||||
|
|
||||||
window.plugins.jPushPlugin.getRegistrationID();
|
|
||||||
window.plugins.jPushPlugin.initNotificationCenter();
|
|
||||||
window.plugins.jPushPlugin.startLogPageView("mianPage");
|
window.plugins.jPushPlugin.startLogPageView("mianPage");
|
||||||
//window.plugins.jPushPlugin.stopLogPageView("mianPage");
|
|
||||||
$("#setTagWithAliasButton").click(function(ev) {
|
$("#setTagWithAliasButton").click(function(ev) {
|
||||||
|
try{
|
||||||
|
var tag1 = $("#tagText1").attr("value");
|
||||||
|
var tag2 = $("#tagText2").attr("value");
|
||||||
|
var tag3 = $("#tagText3").attr("value");
|
||||||
|
var alias = $("#aliasText").attr("value");
|
||||||
|
var dd = [];
|
||||||
|
|
||||||
try{
|
if(tag1==""&&tag2==""&&tag3==""){
|
||||||
var tag1 = $("#tagText1").attr("value");
|
|
||||||
var tag2 = $("#tagText2").attr("value");
|
|
||||||
var tag3 = $("#tagText3").attr("value");
|
|
||||||
|
|
||||||
var alias = $("#aliasText").attr("value");
|
|
||||||
|
|
||||||
var dd = [];
|
|
||||||
|
|
||||||
if(tag1==""&&tag2==""&&tag3==""){
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(tag1 != "")
|
|
||||||
dd.push(tag1);
|
|
||||||
if(tag2 != "")
|
|
||||||
dd.push(tag2);
|
|
||||||
if(tag3 != "")
|
|
||||||
dd.push(tag3);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("dd:"+dd);
|
|
||||||
window.plugins.jPushPlugin.setTagsWithAlias(dd,"");
|
|
||||||
}
|
}
|
||||||
catch(exception){
|
else{
|
||||||
console.log(exception);
|
if(tag1 != ""){
|
||||||
|
dd.push(tag1);
|
||||||
|
}
|
||||||
|
if(tag2 != ""){
|
||||||
|
dd.push(tag2);
|
||||||
|
}
|
||||||
|
if(tag3 != ""){
|
||||||
|
dd.push(tag3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
window.plugins.jPushPlugin.setTagsWithAlias(dd,"");
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
|
||||||
document.addEventListener("networkDidSetup", onDidSetup, false)
|
document.addEventListener("deviceready", onDeviceReady, false);
|
||||||
document.addEventListener("networkDidClose", onDidClose, false)
|
|
||||||
document.addEventListener("networkDidRegister", onDidRegister, false)
|
|
||||||
document.addEventListener("networkDidLogin", onDidLogin, false)
|
|
||||||
|
|
||||||
document.addEventListener("setTagsWithAlias", onTagsWithAlias, false)
|
|
||||||
document.addEventListener("registrationID", onGetRegistradionID, false)
|
|
||||||
document.addEventListener("deviceready", onDeviceReady, false)
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -145,10 +86,6 @@
|
|||||||
<label>RegistrationID: </label>
|
<label>RegistrationID: </label>
|
||||||
<label id="registrationid">null</label>
|
<label id="registrationid">null</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<label>connected state: </label>
|
|
||||||
<label id="connectState">未连接</label>
|
|
||||||
</div>
|
|
||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
<label>Tags: </label>
|
<label>Tags: </label>
|
||||||
<table>
|
<table>
|
||||||
@ -183,7 +120,6 @@
|
|||||||
<div data-role="fieldcontain">
|
<div data-role="fieldcontain">
|
||||||
<label id="tagAliasResult" >null</label>
|
<label id="tagAliasResult" >null</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
||||||
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
||||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
|
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
|
||||||
-(void)initNotifacationCenter:(CDVInvokedUrlCommand*)command;
|
|
||||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
|
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
|
||||||
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
|
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
@implementation JPushPlugin
|
@implementation JPushPlugin
|
||||||
|
|
||||||
|
|
||||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{
|
||||||
|
|
||||||
NSArray *arguments=command.arguments;
|
NSArray *arguments=command.arguments;
|
||||||
@ -21,18 +20,15 @@
|
|||||||
}
|
}
|
||||||
NSString *alias=[arguments objectAtIndex:0];
|
NSString *alias=[arguments objectAtIndex:0];
|
||||||
NSArray *arrayTags=[arguments objectAtIndex:1];
|
NSArray *arrayTags=[arguments objectAtIndex:1];
|
||||||
// NSArray *tags=[arguments subarrayWithRange:range];
|
|
||||||
NSSet* set=[NSSet setWithArray:arrayTags];
|
NSSet* set=[NSSet setWithArray:arrayTags];
|
||||||
[APService setTags:set
|
[APService setTags:set
|
||||||
alias:alias
|
alias:alias
|
||||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||||
object:self];
|
object:self];
|
||||||
//[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setTags:(CDVInvokedUrlCommand *)command{
|
-(void)setTags:(CDVInvokedUrlCommand *)command{
|
||||||
|
|
||||||
//CDVPluginResult *pluginResult=nil;
|
|
||||||
|
|
||||||
NSArray *arguments=[command arguments];
|
NSArray *arguments=[command arguments];
|
||||||
NSString *tags=[arguments objectAtIndex:0];
|
NSString *tags=[arguments objectAtIndex:0];
|
||||||
@ -41,89 +37,52 @@
|
|||||||
[APService setTags:[NSSet setWithArray:array]
|
[APService setTags:[NSSet setWithArray:array]
|
||||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||||
object:self];
|
object:self];
|
||||||
//[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setAlias:(CDVInvokedUrlCommand *)command{
|
-(void)setAlias:(CDVInvokedUrlCommand *)command{
|
||||||
|
|
||||||
CDVPluginResult *pluginResult=nil;
|
|
||||||
|
|
||||||
NSArray *arguments=[command arguments];
|
NSArray *arguments=[command arguments];
|
||||||
[APService setAlias:[arguments objectAtIndex:0]
|
[APService setAlias:[arguments objectAtIndex:0]
|
||||||
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
callbackSelector:@selector(tagsWithAliasCallback:tags:alias:)
|
||||||
object:self];
|
object:self];
|
||||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||||
NSString* registratonID = [APService registrionID];
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
//
|
|
||||||
NSString *script=[NSString stringWithFormat:@"cordova.fireDocumentEvent('registrationID','[%@]')",registratonID];
|
|
||||||
[self.commandDelegate evalJs:script];
|
|
||||||
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.registrationCallback('%@')",registratonID]];
|
|
||||||
});
|
|
||||||
|
|
||||||
|
NSString* registratonID = [APService registrionID];
|
||||||
|
CDVPluginResult *result=[self pluginResultForValue:registratonID];
|
||||||
|
if (result) {
|
||||||
|
[self succeedWithPluginResult:result withCallbackID:command.callbackId];
|
||||||
|
} else {
|
||||||
|
[self failWithCallbackID:command.callbackId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
|
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
|
||||||
|
|
||||||
|
|
||||||
NSLog(@"recode is %d tags is %@ alias %@",resultCode,tags,alias);
|
|
||||||
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:
|
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithInt:resultCode],@"resultCode",
|
[NSNumber numberWithInt:resultCode],@"resultCode",
|
||||||
tags==nil?[NSNull null]:[tags allObjects],@"resultTags",
|
tags==nil?[NSNull null]:[tags allObjects],@"tags",
|
||||||
alias==nil?[NSNull null]:alias,@"resultAlias",nil];
|
alias==nil?[NSNull null]:alias,@"alias",nil];
|
||||||
|
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
||||||
|
[data setObject:[NSNumber numberWithInt:resultCode] forKey:@"resultCode"];
|
||||||
|
[data setObject:tags==nil?[NSNull null]:[tags allObjects] forKey:@"tags"];
|
||||||
|
[data setObject:alias==nil?[NSNull null]:alias forKey:@"alias"];
|
||||||
NSError *error;
|
NSError *error;
|
||||||
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('setTagsWithAlias','[%@]')",jsonString]];
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
|
||||||
|
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
|
||||||
[self writeJavascript:[NSString stringWithFormat:@"window.plugins.jPushPlugin.pushCallback('%@')",jsonString]];
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
- (void)networkDidSetup:(NSNotification *)notification {
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('networkDidSetup')"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)networkDidClose:(NSNotification *)notification {
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('networkDidClose')"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)networkDidRegister:(NSNotification *)notification {
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('networkDidRegister')"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)networkDidLogin:(NSNotification *)notification {
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('networkDidLogin')"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)initNotifacationCenter:(CDVInvokedUrlCommand*)command{
|
|
||||||
|
|
||||||
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
|
|
||||||
|
|
||||||
[defaultCenter addObserver:self
|
|
||||||
selector:@selector(networkDidSetup:)
|
|
||||||
name:kAPNetworkDidSetupNotification
|
|
||||||
object:nil];
|
|
||||||
[defaultCenter addObserver:self
|
|
||||||
selector:@selector(networkDidClose:)
|
|
||||||
name:kAPNetworkDidCloseNotification
|
|
||||||
object:nil];
|
|
||||||
[defaultCenter addObserver:self
|
|
||||||
selector:@selector(networkDidRegister:)
|
|
||||||
name:kAPNetworkDidRegisterNotification
|
|
||||||
object:nil];
|
|
||||||
[defaultCenter addObserver:self
|
|
||||||
selector:@selector(networkDidLogin:)
|
|
||||||
name:kAPNetworkDidLoginNotification
|
|
||||||
object:nil];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
|
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
|
||||||
NSArray *arguments=command.arguments;
|
NSArray *arguments=command.arguments;
|
||||||
if (!arguments||[arguments count]<1) {
|
if (!arguments||[arguments count]<1) {
|
||||||
@ -148,5 +107,39 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)failWithCallbackID:(NSString *)callbackID {
|
||||||
|
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
|
||||||
|
}
|
||||||
|
- (void)succeedWithPluginResult:(CDVPluginResult *)result withCallbackID:(NSString *)callbackID {
|
||||||
|
[self.commandDelegate sendPluginResult:result callbackId:callbackID];
|
||||||
|
}
|
||||||
|
- (CDVPluginResult *)pluginResultForValue:(id)value {
|
||||||
|
|
||||||
|
CDVPluginResult *result;
|
||||||
|
if ([value isKindOfClass:[NSString class]]) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||||
|
messageAsString:[value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||||
|
CFNumberType numberType = CFNumberGetType((CFNumberRef)value);
|
||||||
|
//note: underlyingly, BOOL values are typedefed as char
|
||||||
|
if (numberType == kCFNumberIntType || numberType == kCFNumberCharType) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:[value intValue]];
|
||||||
|
} else {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[value doubleValue]];
|
||||||
|
}
|
||||||
|
} else if ([value isKindOfClass:[NSArray class]]) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:value];
|
||||||
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:value];
|
||||||
|
} else if ([value isKindOfClass:[NSNull class]]) {
|
||||||
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||||
|
} else {
|
||||||
|
NSLog(@"Cordova callback block returned unrecognized type: %@", NSStringFromClass([value class]));
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,139 +1,88 @@
|
|||||||
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
|
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
|
||||||
var JPushPlugin = function(){
|
var JPushPlugin = function(){
|
||||||
|
|
||||||
};
|
};
|
||||||
JPushPlugin.prototype.call_native = function ( name, args) {
|
|
||||||
|
|
||||||
ret = cordova.exec(null,
|
JPushPlugin.prototype.error_callback = function(msg){
|
||||||
null,
|
console.log("Javascript Callback Error: " + msg)
|
||||||
'JPushPlugin',
|
|
||||||
name,
|
|
||||||
args);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
JPushPlugin.prototype.getRegistrationID = function () {
|
|
||||||
|
|
||||||
this.call_native( "getRegistrationID", null);
|
|
||||||
|
|
||||||
|
JPushPlugin.prototype.call_native = function(name, args, callback){
|
||||||
|
ret = cordova.exec(callback,this.error_callback,'JPushPlugin',name,args);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
JPushPlugin.prototype.startLogPageView = function (data) {
|
|
||||||
if (data==null || typeof(data)=="undefined" || data==""){
|
|
||||||
console.log("argument is null");
|
|
||||||
|
|
||||||
|
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{
|
if(alias==null){
|
||||||
this.call_native( "startLogPageView", [data]);
|
this.setTags(tags);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
var arrayTagWithAlias=[tags];
|
||||||
JPushPlugin.prototype.stopLogPageView = function (data) {
|
arrayTagWithAlias.unshift(alias);
|
||||||
if (data==null || typeof(data)=="undefined" || data==""){
|
this.call_native( "setTagsWithAlias", arrayTagWithAlias,null);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setTagsWithAlias = function (tags,alias) {
|
JPushPlugin.prototype.setTags = function(data){
|
||||||
|
|
||||||
if(tags==null){
|
try{
|
||||||
this.setAlias(alias);
|
this.call_native("setTags",[data],null);
|
||||||
return;
|
}
|
||||||
}
|
catch(exception){
|
||||||
if(alias==null){
|
console.log(exception);
|
||||||
this.setTags(tags);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
var arrayTagWithAlias=[tags];
|
|
||||||
arrayTagWithAlias.unshift(alias);
|
|
||||||
this.call_native( "setTagsWithAlias", arrayTagWithAlias);
|
|
||||||
}
|
}
|
||||||
JPushPlugin.prototype.setTags = function (data) {
|
|
||||||
|
|
||||||
try{
|
JPushPlugin.prototype.setAlias = function(data){
|
||||||
this.call_native("setTags", [data]);
|
try{
|
||||||
}
|
this.call_native("setAlias", [data],null);
|
||||||
catch(exception){
|
}
|
||||||
console.log(exception);
|
catch(exception){
|
||||||
}
|
console.log(exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JPushPlugin.prototype.setAlias = function (data) {
|
|
||||||
|
|
||||||
try{
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//android
|
||||||
|
//ios
|
||||||
|
|
||||||
this.call_native("setAlias", [data]);
|
JPushPlugin.prototype.initNotificationCenter = function(){
|
||||||
}
|
this.call_native( "initNotifacationCenter", null,null);
|
||||||
catch(exception){
|
}
|
||||||
|
|
||||||
console.log(exception);
|
if(!window.plugins){
|
||||||
}
|
window.plugins = {};
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!window.plugins) {
|
|
||||||
window.plugins = {};
|
|
||||||
}
|
|
||||||
if(!window.plugins.jPushPlugin){
|
if(!window.plugins.jPushPlugin){
|
||||||
window.plugins.jPushPlugin = new JPushPlugin();
|
window.plugins.jPushPlugin = new JPushPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new JPushPlugin();
|
module.exports = new JPushPlugin();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user