add event jpush.receiveNotification in object-c file

This commit is contained in:
zhangqinghe 2015-03-10 16:46:44 +08:00
parent aae9e8314a
commit 27c4fe7b26

View File

@ -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