mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-22 05:53:04 +08:00
add open notificaiton event when app run background
This commit is contained in:
parent
bf003c84c1
commit
a049e2e62d
@ -27,15 +27,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var onOpenNotification = function(event){
|
var onOpenNotification = function(event){
|
||||||
try{
|
try{
|
||||||
var alert = event.alert;
|
|
||||||
var extras = event.extras;
|
var alert = event.aps.alert;
|
||||||
console.log(alert);
|
console.log("JPushPlugin:onPpenNotification key aps.alert:"+alert);
|
||||||
//console.log(extras);
|
}
|
||||||
}
|
catch(exception){
|
||||||
catch(exeption){
|
console.log("JPushPlugin:onPpenNotification"+exception);
|
||||||
console.log(exception)
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var onReceiveNotification = function(event){
|
var onReceiveNotification = function(event){
|
||||||
try{
|
try{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#import "JPushPlugin.h"
|
#import "JPushPlugin.h"
|
||||||
#import "APService.h"
|
#import "APService.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@implementation JPushPlugin
|
@implementation JPushPlugin
|
||||||
|
|
||||||
@ -275,10 +276,29 @@
|
|||||||
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
switch ([UIApplication sharedApplication].applicationState) {
|
||||||
|
case UIApplicationStateActive:
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UIApplicationStateInactive:
|
||||||
|
case UIApplicationStateBackground:
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user