来自firebase web api的Ios图像通知使用php

时间:2017-05-03 04:02:43

标签: php ios firebase

我正在向ios发送通知。没有图像的通知工作正常但不是图像。当我搜索解决方案时,他们都说像set'mutable-content'=>真正。是的,但是怎么样?我可能是如此愚蠢到不明白这实际意味着什么。我发送的参数就是这个..

$arr = ['type' => 'msg', 'data' => '', 'text' => 'Hello', 'image_url' => ''];
$fields = array(
           'to' => '/topics/iostest',
           'notification' => $arr,
           'mutable-content'=> 1,
           'priority' => 'high'
          );

Ios只阅读'通知'并收到类似..

'aps': {
   alert : 'Hello'
}

没有收到'可变内容'...... 我希望,在ios和php上工作的人可以解决这个问题。请帮忙。感谢。

2 个答案:

答案 0 :(得分:0)

将此json格式用于来自firebase的推送通知,您的json fromat应为

{ "registration_ids" : [Send Array of Device Token], "data" : {
"image_url" : "send your image here"
  "message" : "Send your message here" },"notification" : {
"title" : "APP Name",
"sound" : "default",
"priority" : "high" }}

答案 1 :(得分:0)

检查JSON中的 mutable-content 一词。请设置 mutable_content 而不是 mutable-content 。 APNS会自动转换它。

使用以下JSON格式进行丰富的推送通知 注意:JSON中的 content_available 字段是可选的, mutable_content 是必需的。

{
   "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"
   }
}

你应该得到像这样的有效载荷

{

aps =     {

    alert = "Enter your message";

    "content-available" = 1;

    "mutable-content" = 1;

    sound = default;

};

"gcm.message_id" = "0:1498075182894674%4e5015e84e5015e8";

mediaUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG";

message = "Offer!";

}