mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-22 05:53:04 +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:)
|
selector:@selector(networkDidReceiveMessage:)
|
||||||
name:kJPFNetworkDidReceiveMessageNotification
|
name:kJPFNetworkDidReceiveMessageNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
[defaultCenter addObserver:self
|
||||||
|
selector:@selector(networkDidReceiveNotification:)
|
||||||
|
name:kJPushPluginReceiveNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -195,13 +200,13 @@
|
|||||||
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||||
|
|
||||||
NSDictionary *userInfo = [notification userInfo];
|
NSDictionary *userInfo = [notification userInfo];
|
||||||
NSLog(@"%@",userInfo);
|
//NSLog(@"%@",userInfo);
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
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];
|
||||||
|
|
||||||
NSLog(@"%@",jsonString);
|
//NSLog(@"%@",jsonString);
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
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
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user