From 42c2fbc8f38febe6261b3b209be86e49b3aea7dc Mon Sep 17 00:00:00 2001 From: qzl Date: Fri, 20 Mar 2026 18:48:22 +0800 Subject: [PATCH] feat(ios): write notification payload to UserDefaults on tap --- apps/ios/Runner/AppDelegate.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/ios/Runner/AppDelegate.swift b/apps/ios/Runner/AppDelegate.swift index 1e8d67e..5c3053e 100644 --- a/apps/ios/Runner/AppDelegate.swift +++ b/apps/ios/Runner/AppDelegate.swift @@ -18,4 +18,17 @@ import UserNotifications } return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + override func userNotificationCenter( + _ center: UNUserNotificationCenter, + didReceive response: UNNotificationResponse, + withCompletionHandler completionHandler: @escaping () -> Void + ) { + let userInfo = response.notification.request.content.userInfo + if let jsonData = try? JSONSerialization.data(withJSONObject: userInfo, options: []), + let jsonString = String(data: jsonData, encoding: .utf8) { + UserDefaults.standard.set(jsonString, forKey: "pending_notification_payload") + } + completionHandler() + } }