APN自定义通知声音问题 [英] APN custom notification sound issue

查看:33
本文介绍了APN自定义通知声音问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了远程通知并且工作正常.但是,当收到通知时(当应用程序不在前台时),我必须播放自定义声音.我在我的应用程序包中添加了一个名为 customSound.wav 的文件,并确保在我将它拖放到我的项目中时选择了添加到目标"(这是正确的方法吗?).服务器端:相同的文件名已被指定为 "sound": "customSound.wav".在我的 didReceiveRemoteNotification 中,我正在打印 userInfo 字典,它是这样出现的:

I have remote notifications setup and working fine. I however have to play a custom sound when a notification is received (when app is NOT in foreground). I have added a file called customSound.wav to my app bundle and made sure "add to targets" is selected when i drag and drop it into my project (is this the correct way?). Server-side: the same file name has been specified as "sound": "customSound.wav". In my didReceiveRemoteNotification i am printing the userInfo dictionary and it is coming up like this:

aps =     
{
    alert = "Good Evening Sir";
    badge = 1;
    "custom_filed1" = 1;
    "custom_field2" = "AAA-BBB-CCC";
    name = "Sir Hubert";
    sound = default;
};

如您所见,声音仍然是默认".我知道如果找不到指定的声音,则播放默认声音 - 字典中的声音值是否也为默认"或应该是有效负载 json 中指定的文件名.这些在有效载荷中指定的顺序是否重要.我尝试了其他线程的建议,但对我不起作用.我无法显示 json,因为我目前无法访问系统.关于我可能做错了什么的任何建议?

As you can see, sound is still "default". I am aware of the fact that if the sound specified can not be found, the default sound is played- will the sound value in the dictionary also be "default" or it should be the file name that was specified in payload json. Is the order in which these are specified in the payload important. I have tried suggestions from other threads but not working for me. I can not show the json as I do not have access to the system at the moment. Any suggestions as to what I may be doing wrong ?

推荐答案

不,你的声音键应该有你想播放的声音文件名.

No your sound key should have the sound file name you want to play.

{
  aps =
  {
    alert = "message";
    sound = "sound file name.extension";
    badge = 1;
  };
}

例如:{aps ={警报=消息";sound = "tone.caf";};}

eg: { aps = { alert = "message"; sound = "tone.caf"; }; }

我正在使用它并在我的通知中获得成功的自定义警报;尽可能缩短声音持续时间.我用这种文件格式做了:aiff, caf

I am using this and getting successful custom alert on my notification; keep sound duration as small as possible. I did with this file format: aiff, caf

如果你想测试通知,那么你可以试试这个应用程序 https://itunes.apple.com/us/app/easy-apns-provider-push-notification/id989622350?mt=12

我没有对这个应用做任何标记,但它非常适合测试推送通知

这篇关于APN自定义通知声音问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆