自定义声音推送通知

huangapple go评论73阅读模式
英文:

Custom sound push notification

问题

I am receiving notification payload as

[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]

It does not add sound name in aps alert. Will it be done from backend?
We are using JAVA for Backend.

英文:

I am receiving notification payload as

    [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]

It does not add sound name in aps alert. Will it be done from backend?
We are using JAVA for Backend.

答案1

得分: 2

我认为声音属性必须设置为 aps 的属性,而不是 alert 对象的属性,就像您现在收到的一样,以及在 苹果文档 中指定的那样。苹果示例:

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

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

英文:

I believe the sound property has to be set as a property of the aps and not of the alert object, like you're receiving now and like it is specified in apple documentation. Apple example:

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

You should specify the string "default" to play the default notification sound, otherwise a filename must be set and the file needs to exist on the app. These changes would have to be done on the server side.

huangapple
  • 本文由 发表于 2020年8月14日 03:49:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63402285.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定