mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-04-29 14:00:10 +08:00
fix backgroup notification event fire twice
This commit is contained in:
parent
4f0c186bc3
commit
7f2179fe32
@ -156,7 +156,7 @@ NSDictionary *_launchOptions;
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||||
NSMutableDictionary *userInfo = @[].mutableCopy;
|
NSMutableDictionary *userInfo = @{}.mutableCopy;
|
||||||
|
|
||||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||||
@ -169,6 +169,10 @@ NSDictionary *_launchOptions;
|
|||||||
userInfo[@"identifier"] = notification.request.identifier;
|
userInfo[@"identifier"] = notification.request.identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user