iOS - 通过 FCM 向 APNs 发送推送通知图片无法工作

4

尝试使用Firebase Cloud Messaging将图像发送到APNs,但是Firebase文档中的有效载荷并不起作用。

Firebase文档:https://firebase.google.com/docs/cloud-messaging/ios/send-image

## Request
curl -X "POST" "https://fcm.googleapis.com/fcm/send" \
     -H 'Content-Type: application/json' \
     -H 'Authorization: key={web_token}' \
     -d $'{
  "to": "fcm_token",
  "priority": "high",
  "apns": {
    "payload": {
      "aps": {
        "mutable-content": 1
      }
    },
    "fcm_options": {
      "image": "mage_urli"
    }
  },
  "data": {
    "Room": "PortugalVSDenmark",
    "Nick": "Mario"
  },
  "notification": {
    "title": "Portugal vs. Denmark",
    "body": "great match!"
  }
}'

我也在尝试让它工作,但遇到了麻烦。首先,我认为headers需要与fcm_options处于同一级别,而不应该在payload内部。https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsFcmOptions其次,您是否执行了任何额外的操作以启用UserNotificationsUI / UNNotificationContentExtension?https://dev59.com/dFoU5IYBdhLWcg3wFEE6 https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension - vesperknight
1个回答

2

我遇到了同样的问题,我在负载中的通知字段中添加了图像,这解决了问题。

以下是一个例子:

"notification": {
  "title": "Portugal vs. Denmark",
  "body": "great match!",
  "image": "image-url"}

看起来文档相当错误。


你应该得到一个奖项。好样的伙计;-) 谢谢。它对我很有用!!! - immodi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接