Изображение в Pu sh Уведомление об облачных сообщениях Firebase не отображается в push-уведомлениях - PullRequest
0 голосов
/ 16 июня 2020

У меня работает FCM, но изображение, которое я установил в консоли Firebase, не отображается в уведомлении pu sh.

Я создал расширение службы уведомлений и добавил вспомогательный обработчик завершения FCM, но изображение все еще не отображается в уведомлении pu sh.

У меня такое ощущение, что с моей службой уведомлений что-то не так. Любая помощь приветствуется!

import UserNotifications
import FirebaseMessaging
import Foundation
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)

        if let bestAttemptContent = bestAttemptContent {
            let attachmentUrlAsString = bestAttemptContent.userInfo["url"] as? String ?? ""
            // Modify the notification content here...
            bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"

            Messaging.serviceExtension().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
        }
    }

    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)
        }
    }

}
...