Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions SampleApp/ios/SampleApp/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@ - (UISceneConfiguration *)application:(UIApplication *)application
return config;
}

#pragma mark - UNUserNotificationCenterDelegate
//
// Mirrors the canonical pattern in MoEngageTestApp/AppDelegate.swift:241-245 — forwards
// the notification to the MoEngage SDK for analytics + inbox + impression tracking, then
// tells iOS what to display in foreground via `completionHandler`. Without these methods
// iOS suppresses the foreground banner because the SDK's proxy default is `[]`.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
[[MoEngageSDKMessaging sharedInstance] userNotificationCenter:center
willPresent:notification];
completionHandler(UNNotificationPresentationOptionAlert
| UNNotificationPresentationOptionSound
| UNNotificationPresentationOptionBadge);
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
[[MoEngageSDKMessaging sharedInstance] userNotificationCenter:center
didReceive:response];
completionHandler();
}

@end
27 changes: 27 additions & 0 deletions SampleApp/ios/SampleSwiftApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,30 @@ class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
#endif
}
}

// MARK: - UNUserNotificationCenterDelegate
//
// Mirrors the canonical pattern in MoEngageTestApp/AppDelegate.swift:241-245 — forwards
// the notification to the MoEngage SDK for analytics + inbox + impression tracking, then
// tells iOS what to display in foreground via `completionHandler`. Without these methods
// iOS suppresses the foreground banner because the SDK's proxy default is `[]`.
extension AppDelegate {

func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
MoEngageSDKMessaging.sharedInstance.userNotificationCenter(center, willPresent: notification)
completionHandler([.alert, .sound, .badge])
}

func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
MoEngageSDKMessaging.sharedInstance.userNotificationCenter(center, didReceive: response)
completionHandler()
}
}
Loading