From e03ff6d19d2d879e6a12580e8a54f0d8f51c5358 Mon Sep 17 00:00:00 2001 From: Brandon Stalnaker <33703490+BrandonStalnaker@users.noreply.github.com> Date: Mon, 2 Oct 2023 09:37:22 -0400 Subject: [PATCH] fix:Correct Push Notifications for Notification Center (#81) --- Sources/mParticle-Appboy/MPKitAppboy.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/mParticle-Appboy/MPKitAppboy.m b/Sources/mParticle-Appboy/MPKitAppboy.m index d3d5cc3..439fd7a 100644 --- a/Sources/mParticle-Appboy/MPKitAppboy.m +++ b/Sources/mParticle-Appboy/MPKitAppboy.m @@ -564,7 +564,7 @@ - (MPKitExecStatus *)receivedUserNotification:(NSDictionary *)userInfo { #if TARGET_OS_IOS if (![appboyInstance.notifications handleBackgroundNotificationWithUserInfo:userInfo fetchCompletionHandler:^(UIBackgroundFetchResult fetchResult) {}]) { - execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeFail]; + NSLog(@"mParticle -> Invalid Braze remote notification: %@", userInfo); } #endif @@ -933,11 +933,21 @@ - (MPKitExecStatus *)setUserIdentity:(NSString *)identityString identityType:(MP } #if TARGET_OS_IOS +- (nonnull MPKitExecStatus *)userNotificationCenter:(nonnull UNUserNotificationCenter *)center willPresentNotification:(nonnull UNNotification *)notification { + MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess]; + + if (![appboyInstance.notifications handleBackgroundNotificationWithUserInfo:notification.request.content.userInfo fetchCompletionHandler:^(UIBackgroundFetchResult fetchResult) {}]) { + NSLog(@"mParticle -> Invalid Braze remote notification: %@", notification.request.content.userInfo); + } + + return execStatus; +} + - (nonnull MPKitExecStatus *)userNotificationCenter:(nonnull UNUserNotificationCenter *)center didReceiveNotificationResponse:(nonnull UNNotificationResponse *)response API_AVAILABLE(ios(10.0)) { MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeSuccess]; if (![appboyInstance.notifications handleUserNotificationWithResponse:response withCompletionHandler:^{}]) { - execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppboy) returnCode:MPKitReturnCodeFail]; + NSLog(@"mParticle -> Notification Response rejected by Braze: %@", response); } return execStatus;