mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-05-08 03:19:17 +08:00
iOS - new feature
1. 增加 jpush.backgroundNotification 事件 2. 重新区分原有事件的触发条件 3. 更新 文档接口说明
This commit is contained in:
parent
d1e4f70188
commit
95c9b12124
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user