mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 04:42:53 +08:00
add event jpush.receiveNotification in object-c file
This commit is contained in:
parent
aae9e8314a
commit
27c4fe7b26
@ -19,6 +19,11 @@
|
||||
selector:@selector(networkDidReceiveMessage:)
|
||||
name:kJPFNetworkDidReceiveMessageNotification
|
||||
object:nil];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(networkDidReceiveNotification:)
|
||||
name:kJPushPluginReceiveNotification
|
||||
object:nil];
|
||||
|
||||
|
||||
}
|
||||
@ -195,13 +200,13 @@
|
||||
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||
|
||||
NSDictionary *userInfo = [notification userInfo];
|
||||
NSLog(@"%@",userInfo);
|
||||
//NSLog(@"%@",userInfo);
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
|
||||
NSLog(@"%@",jsonString);
|
||||
//NSLog(@"%@",jsonString);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
@ -211,4 +216,19 @@
|
||||
|
||||
}
|
||||
|
||||
-(void)networkDidReceiveNotification:(id)notification{
|
||||
|
||||
NSError *error;
|
||||
NSDictionary *userInfo = [notification object];
|
||||
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user