APN自定义通知发出的声音 [英] APN custom notification sound issue

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

问题描述

我有远程通知设置和工作的罚款。然而,我有当收到通知播放自定义声音(当应用程序是不是在前台)。我添加了一个名为customSound.wav文件,以我的应用程序包,并确保添加到目标时,当我将它拖放到我的项目(​​这是正确的方式?)。服务器端:相同的文件名已被指定为声音:customSound.wav。在我didReceiveRemoteNotification我正在打印的用户信息字典,它是未来像这样:

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;
};

正如你所看到的,声音依然是默认。我知道的事实,如果指定的声音无法找到,默认的声音played-将在字典中的公允价值也将默认,或者它应该是在有效载荷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 =
      {
        警报=消息;
        听起来=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

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

我没有做这个应用程序的任何标记,但它是很好的测试推送通知

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

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