为本地通知选择自定义声音

编程入门 行业动态 更新时间:2024-10-27 00:35:47
本文介绍了为本地通知选择自定义声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何更改播放本地通知的声音?我使用下面的代码播放默认声音:

How do you change the sound that plays for local notifications? I use the code below to play the default sound:

notif.soundName = UILocalNotificationDefaultSoundName;

所以,我在下面尝试了这个,但它没有用。我该怎么办?谢谢你的帮助!

So, I tried this below, and it didn't work. What should I do? Thanks for your help!

notif.soundName = @"sound.caf";

推荐答案

这应该有效。确保声音实际上在您的应用程序包中,格式正确(线性PCM或IMA4 - 几乎任何解释如何转换iOS声音的地方都会告诉您如何操作),并且不到30秒。

That should work. Make sure the sound is actually in your app’s bundle, is in the correct format (linear PCM or IMA4—pretty much anywhere that explains how to convert sounds for iOS will tell you how to do that), and is under 30 seconds.

更多推荐

为本地通知选择自定义声音

本文发布于:2023-11-27 01:59:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636103.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   声音   通知

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!