Skip to content

Commit

Permalink
fix:Correct Push Notifications for Notification Center (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker authored Oct 2, 2023
1 parent a7eeb69 commit e03ff6d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Sources/mParticle-Appboy/MPKitAppboy.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e03ff6d

Please sign in to comment.