Skip to content

Commit

Permalink
fix:Correct Push Notifications Counts for Notification Center (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker authored Oct 2, 2023
1 parent 63fc562 commit b08e840
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 14 additions & 5 deletions mParticle-Apple-SDK/AppNotifications/MPAppNotificationHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ - (void) didReceiveRemoteNotification:(NSDictionary *)userInfo {
event:nil
parameters:queueParameters
messageType:MPMessageTypePushNotification
userInfo:nil
userInfo:userInfo
];
});
}
Expand Down Expand Up @@ -227,7 +227,17 @@ - (void)userNotificationCenter:(nonnull UNUserNotificationCenter *)center willPr

for (id<MPExtensionKitProtocol> kitRegister in activeKitsRegistry) {
if ([kitRegister.wrapperInstance respondsToSelector:userNotificationCenterWillPresentNotification]) {
[kitRegister.wrapperInstance userNotificationCenter:center willPresentNotification:notification];
MPKitExecStatus *execStatus = [kitRegister.wrapperInstance userNotificationCenter:center willPresentNotification:notification];

if (execStatus.success) {
MPForwardRecord *forwardRecord = [[MPForwardRecord alloc] initWithMessageType:MPMessageTypePushNotification execStatus:execStatus];

dispatch_async([MParticle messageQueue], ^{
[[MParticle sharedInstance].persistenceController saveForwardRecord:forwardRecord];
});

MPILogDebug(@"Forwarded user notifications call to kit: %@", kitRegister.name);
}
}
}
});
Expand Down Expand Up @@ -255,14 +265,13 @@ - (void)userNotificationCenter:(nonnull UNUserNotificationCenter *)center didRec
MPKitExecStatus *execStatus = [kitRegister.wrapperInstance userNotificationCenter:center didReceiveNotificationResponse:response];

if (execStatus.success) {

MPForwardRecord *forwardRecord = [[MPForwardRecord alloc] initWithMessageType:MPMessageTypePushNotification execStatus:execStatus];
MPForwardRecord *forwardRecord = [[MPForwardRecord alloc] initWithMessageType:MPMessageTypePushNotificationInteraction execStatus:execStatus];

dispatch_async([MParticle messageQueue], ^{
[[MParticle sharedInstance].persistenceController saveForwardRecord:forwardRecord];
});

MPILogDebug(@"Forwarded user notifications call to kit: %@", kitRegister.name);
MPILogDebug(@"Forwarded user notifications response call to kit: %@", kitRegister.name);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions mParticle-Apple-SDK/MPEnums.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ + (MPMessageType)messageTypeFromNSString:(NSString *)messageTypeString {
return MPMessageTypeBreadcrumb;
} else if ([messageTypeString isEqualToString:kMPMessageTypeStringProfile]) {
return MPMessageTypeProfile;
} else if ([messageTypeString isEqualToString:kMPMessageTypeStringPushNotification]) {
return MPMessageTypePushNotification;
} else if ([messageTypeString isEqualToString:kMPMessageTypeStringPushNotificationInteraction]) {
return MPMessageTypePushNotificationInteraction;
} else if ([messageTypeString isEqualToString:kMPMessageTypeStringCommerceEvent]) {
Expand Down

0 comments on commit b08e840

Please sign in to comment.