From 6d6563f96319dc8b33b16a2aa7e4e05b33b18295 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Tue, 3 Feb 2026 14:03:29 -0500 Subject: [PATCH] fix iOS notifications --- .../NotificationService.swift | 84 ++++++++++--------- ios/Runner.xcodeproj/project.pbxproj | 2 +- scripts/add-firebase-messaging.sh | 2 +- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/ios/Notification Service Extension/NotificationService.swift b/ios/Notification Service Extension/NotificationService.swift index 9d464e127..20d3b8800 100644 --- a/ios/Notification Service Extension/NotificationService.swift +++ b/ios/Notification Service Extension/NotificationService.swift @@ -13,51 +13,53 @@ class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent? - override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { - self.contentHandler = contentHandler - bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) + // #Pangea + // override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { + // self.contentHandler = contentHandler + // bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) - if let bestAttemptContent = bestAttemptContent { - // Uncomment to read the push message payload: - // os_log("[FluffyChatPushHelper] New message received: %{public}@", log: .default, type: .error, bestAttemptContent.userInfo) - os_log("[FluffyChatPushHelper] New message received") + // if let bestAttemptContent = bestAttemptContent { + // // Uncomment to read the push message payload: + // // os_log("[FluffyChatPushHelper] New message received: %{public}@", log: .default, type: .error, bestAttemptContent.userInfo) + // os_log("[FluffyChatPushHelper] New message received") - guard let roomId = bestAttemptContent.userInfo["room_id"] as? String, - let eventId = bestAttemptContent.userInfo["event_id"] as? String else { - os_log("[FluffyChatPushHelper] Room ID or Event ID is missing!") - let emptyContent = UNMutableNotificationContent() - contentHandler(emptyContent) - return - } - bestAttemptContent.threadIdentifier = roomId + // guard let roomId = bestAttemptContent.userInfo["room_id"] as? String, + // let eventId = bestAttemptContent.userInfo["event_id"] as? String else { + // os_log("[FluffyChatPushHelper] Room ID or Event ID is missing!") + // let emptyContent = UNMutableNotificationContent() + // contentHandler(emptyContent) + // return + // } + // bestAttemptContent.threadIdentifier = roomId - if - let jsonString = bestAttemptContent.userInfo["counts"] as? String, - let jsonData = jsonString.data(using: .utf8), - let jsonMap = try? JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any], - let unread = jsonMap["unread"] as? Int { - bestAttemptContent.title = String( - localized: "\(unread) unread messages", - comment: "Default notification title" - ) - bestAttemptContent.badge = NSNumber(integerLiteral: unread) - } + // if + // let jsonString = bestAttemptContent.userInfo["counts"] as? String, + // let jsonData = jsonString.data(using: .utf8), + // let jsonMap = try? JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any], + // let unread = jsonMap["unread"] as? Int { + // bestAttemptContent.title = String( + // localized: "\(unread) unread messages", + // comment: "Default notification title" + // ) + // bestAttemptContent.badge = NSNumber(integerLiteral: unread) + // } - // TODO: Download and decrypt event to display a better body: - bestAttemptContent.body = String( - localized: "New message - open app to read", - comment: "Default notification body" - ) + // // TODO: Download and decrypt event to display a better body: + // bestAttemptContent.body = String( + // localized: "New message - open app to read", + // comment: "Default notification body" + // ) - contentHandler(bestAttemptContent) - } - } + // contentHandler(bestAttemptContent) + // } + // } - override func serviceExtensionTimeWillExpire() { - // Called just before the extension will be terminated by the system. - // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { - contentHandler(bestAttemptContent) - } - } + // override func serviceExtensionTimeWillExpire() { + // // Called just before the extension will be terminated by the system. + // // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. + // if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { + // contentHandler(bestAttemptContent) + // } + // } + // Pangea# } diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 00050fcf3..8d0143c52 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 77; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ diff --git a/scripts/add-firebase-messaging.sh b/scripts/add-firebase-messaging.sh index 596e1ff08..38f17b20f 100755 --- a/scripts/add-firebase-messaging.sh +++ b/scripts/add-firebase-messaging.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -flutter pub add fcm_shared_isolate:0.1.0 +flutter pub add fcm_shared_isolate flutter pub get if [[ "$OSTYPE" == "darwin"* ]]; then