fix backgroup notification event fire twice

This commit is contained in:
huangminlinux 2018-01-31 16:12:11 +08:00
parent 4f0c186bc3
commit 7f2179fe32

View File

@ -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);
}