feat(ios): store notification payload in UserDefaults on tap

This commit is contained in:
qzl
2026-03-20 18:43:53 +08:00
parent af38ca2369
commit 06026530dd
+14
View File
@@ -18,4 +18,18 @@ import UserNotifications
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
@available(iOS 10.0, *)
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()
}
}