fix iOS notifications

This commit is contained in:
ggurdin 2026-02-03 14:03:29 -05:00
parent b21ae7a55a
commit 6d6563f963
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
3 changed files with 45 additions and 43 deletions

View file

@ -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#
}

View file

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 77;
objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */

View file

@ -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