用户收到推送通知时如何播放自定义声音文件? [英] How to play custom sound file when user get push notification?

查看:21
本文介绍了用户收到推送通知时如何播放自定义声音文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序包中有一个声音文件,我想在用户收到推送通知时播放该声音文件.

I have a sound file in the app bundle, i want to play that sound file when user will get push notification.

如果是,是否可以在 iOS 中实现,那么请提出实现此目标的方法.

IS it possible in iOS if yes, then please suggest the way to achieve this.

谢谢,

推荐答案

要播放此声音,您必须在通知负载中指定声音的文件名.例如,假设您已将名为 example.caf 的声音文件添加到您的应用程序中,我们可以使用通知负载播放此声音,如下所示:

To play this sound you must specify the filename of the sound in the notification payload. For example, lets say you've added a sound file named example.caf into your application, we can play this sound with the notification payload as below:

{
    aps =     
    {
        alert = "test example notification message";
        sound = "example.caf";
    };
}

然后自定义声音会在您的通知到达时播放.

Then the custom sound will play when your notification arrives.

这篇关于用户收到推送通知时如何播放自定义声音文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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