自定义声音推送通知

时间:2020-08-13 19:49:43

标签: java ios swift push-notification

我收到的通知有效载荷为

    [AnyHashable("jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("aps"): {
    alert =     {
        body = "You have received a new Order! ";
        title = Orders;
    };
    sound = default;
},AnyHashable("google.c.a.e"): 1, AnyHashable("gcm.notification.jsonData"): {"packageName":"com.company.appName","appName":"AppName","orderId":"0","workflow":"PAGE_OWNER_STATUS_WORKFLOW"}, AnyHashable("title"): Orders, AnyHashable("google.c.sender.id"): 34781329473, AnyHashable("body"): You have received a new Order! , AnyHashable("sound"): phone_ringing.caf, AnyHashable("gcm.message_id"): 1597347128946557]

它不会在aps警报中添加声音名称。会从后端完成吗? 我们正在将JAVA用于后端。

1 个答案:

答案 0 :(得分:1)

我认为声音属性必须设置为aps而不是alert对象的属性,就像您现在正在接收并且在apple documentation中指定它一样。苹果示例:

{
   “aps” : {
      “badge” : 9
      “sound” : “bingbong.aiff”
   },
   “messageID” : “ABCDEFGHIJ”
}

您应该指定字符串“ default”来播放默认的通知声音,否则必须设置文件名并且该文件必须存在于应用程序中。这些更改必须在服务器端进行。