英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论