iOS - new feature

1. 增加 jpush.backgroundNotification 事件
2. 重新区分原有事件的触发条件
3. 更新 文档接口说明
This commit is contained in:
E.B 2016-04-22 15:44:04 +08:00
parent d1e4f70188
commit 95c9b12124
2 changed files with 18 additions and 13 deletions

View File

@ -60,10 +60,11 @@
/* /*
* js中可监听到的事件 * js中可监听到的事件
* jpush.openNotification app * jpush.openNotification app
* jpush.setTagsWithAlias * jpush.setTagsWithAlias
* jpush.receiveMessage * jpush.receiveMessage
* jpush.receiveNotification * jpush.receiveNotification
* jpush.backgoundNotification
*/ */
@end @end

View File

@ -356,29 +356,33 @@ static NSDictionary *_luanchOptions = nil;
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(@"%ld",(long)[UIApplication sharedApplication].applicationState);
switch ([UIApplication sharedApplication].applicationState) { switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateActive: case UIApplicationStateActive:{
{ //
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]]; [self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveNotification',%@)",jsonString]];
}); });
}
break; break;
case UIApplicationStateInactive: }
case UIApplicationStateBackground: case UIApplicationStateInactive:{
{ //
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]]; [self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
}); });
break;
} }
case UIApplicationStateBackground:{
//
dispatch_async(dispatch_get_main_queue(), ^{
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.backgoundNotification',%@)",jsonString]];
});
break; break;
}
default: default:
//do nothing //do nothing
break; break;
} }
} }
@end @end