8

我为我的项目使用FCM。它有丰富的推送通知类型。我试图修改大多数可能的方法来从FCM获得推送。我得到了FCM的普通推送,而不是图像。针对iOS的FCM丰富推送通知负载

我也使用push try检查与APNS相同的编码。我得到了推送通知的预期设计。

这里我APNS有效载荷

{ 
    "aps": { 
    "alert": "Enter your message", 
    "badge": 1, 
    "sound": "default", 
    "content-available": 1, 
    "mutable-content": 1 
    }, 
    "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG" 
} 

这里FCM有效载荷

{ 
    "to": "dWB537Nz1GA:APA91bHIjJ5....", 
    "data": 
    { 
     "message": "Offer!", 
     "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG" 
    }, 
    "notification": 
    { 
     "body": "Enter your message", 
     "sound": "default", 
     "content-available": 1, 
     "mutable-content": 1 
    } 
} 

而且我需要类别more details about payload in FCM

我缺少火灾基地控制台任何设置或者是从有效载荷。

回答

13

您的FCM有效负载中的mutable-contentcontent-available不正确。它应该被格式化为mutable_contentcontent_available。两者都是布尔型且必须也在notification参数之外。像这样:

{ 
    "to": "dWB537Nz1GA:APA91bHIjJ5....", 
    "content_available": true, 
    "mutable_content": true, 
    "data": 
    { 
     "message": "Offer!", 
     "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG" 
    }, 
    "notification": 
    { 
     "body": "Enter your message", 
     "sound": "default" 
    } 
} 

对于category在FCM的对手,你应该使用click_action

与通知用户点击相关联的动作。

对应于类别在APN的有效载荷中。

+1

再次感谢@AL。 – user3589771