mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-21 04:32:59 +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{
|
||||
NSMutableDictionary *userInfo = @[].mutableCopy;
|
||||
NSMutableDictionary *userInfo = @{}.mutableCopy;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||
@ -169,6 +169,10 @@ NSDictionary *_launchOptions;
|
||||
userInfo[@"identifier"] = notification.request.identifier;
|
||||
}
|
||||
|
||||
if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件
|
||||
return;
|
||||
}
|
||||
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user