Push notifications start out simple: show a banner, open the app. Then the product team adds a new notification type, then another, and soon you have twenty of them, each expected to open a different screen. If every type is handled by its own if branch inside the app delegate, the code becomes impossible to maintain.
In this article I'll show the structure I use for FCM and APNs notifications in a UIKit app: one entry point for every notification, typed payloads, local persistence, and a deep-link router that works even when the app was killed.
1. Set up one entry point
All notification events should flow through a single object. Make it the UNUserNotificationCenter delegate, and set it before the app finishes launching, otherwise you can miss a tap that cold-starts the app.
final class NotificationCoordinator : NSObject , UNUserNotificationCenterDelegate { static let shared = NotificationCoordinator ( ) private let router = DeepLinkRouter .…