为什么 HTTP 图片 URL 不能用于 Firebase iOS 推送通知?

Why are HTTP image URLs not working with Firebase iOS push notifications?

我在 JSON 播放负载中为 iOS 推送通知添加了以下选项,它使用 Notification Service Extension.[=17 成功显示了带有图像的通知=]

"fcm_options": {
  "image": "url-to-image"
}

但是,当图像 URL 是 HTTP 而不是 HTTPs 时,它不会填充通知栏中的图像。该图像已成功加载到 App.

内容详细信息页面的 UIImageView

这是我在里面的实现:

override func didReceive(_ request: UNNotificationRequest, 
                             withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void)
{
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

    if let bestAttemptContent = bestAttemptContent {

        // 1. Modify the notification content here...
        bestAttemptContent.title = "\(bestAttemptContent.title)"
        bestAttemptContent.body = "\(bestAttemptContent.body)"

        // 2. Modify badge count
        if let userDefaults = UserDefaults(suiteName: "group.myBundleId") {

            let badgeCount = userDefaults.integer(forKey: "badgeCount")

            if badgeCount > 0 {
                userDefaults.set(badgeCount + 1, forKey: "badgeCount")
                bestAttemptContent.badge = badgeCount + 1 as NSNumber
            } else {
                userDefaults.set(1, forKey: "badgeCount")
                bestAttemptContent.badge = 1
            }
        }

        // 3. Load image

        /* NOTE: Instead of completing the callback with 
                 self.contentHandler(self.bestAttemptContent);,
                 complete it with FIRMessaging extensionHelper */

        //contentHandler(bestAttemptContent)

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

我该怎么办?是否有必要提供图像 URLs 和 HTTPs?

很久以前我做了一个带有丰富推送通知的应用程序,这是我使用的教程 https://medium.com/@lucasgoesvalle/custom-push-notification-with-image-and-interactions-on-ios-swift-4-ffdbde1f457

我希望它能像对我一样对你有所帮助。