设置为本地通知声音在3G版iPhone上运行iOS4的 [英] Setting sounds for local notifications on a 3G iPhone running iOS4

查看:165
本文介绍了设置为本地通知声音在3G版iPhone上运行iOS4的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功预定使用下面的code在我的应用程序的本地通知:

I have successfully scheduled local notifications in my app using the code below:

Class cls = NSClassFromString(@"UILocalNotification");

    if (cls != nil) {

        UILocalNotification *notification = [[cls alloc] init];
        notification.fireDate = self.alarmNotificationDate;
        notification.timeZone = [NSTimeZone defaultTimeZone];

        notification.alertBody = @"Alarm is due";
        notification.alertAction = @"Show Alarm";

        notification.soundName = @"alarm.mp3";

        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        [notification release];

在哪里self.alarmNotificationDate是NSDate的分配中的另一种方法。

Where self.alarmNotificationDate is a NSDate assign in another method.

在模拟器一切工作正常,但是当我在我的信任的旧款iPhone 3G测试运行iOS4的我得到的通知,但只使用默认的声音。

All works fine in the simulator, but when I test on my trusted old iPhone 3G running iOS4 I get the notification, but only with the default sound.

我曾尝试与不同的声音文件,但没有成功。

I have tried with different sound files but no success.

任何线索为什么会是这样,如何​​纠正呢?

Any clue why it could be like this and how to correct it?

感谢

推荐答案

UILocalNotification不支持MP3。它只支持参考页中提到的格式和容器。

UILocalNotification does not support mp3. It only supports the formats and containers mentioned on the reference page.

<一个href=\"http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html\">http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

由于定制警报播放声音
  加上iOS系统声音设备,他们
  必须在以下的音频之一
  数据格式:

Because custom alert sounds are played by the iOS system-sound facility, they must be in one of the following audio data formats:

  Linear PCM
  MA4 (IMA/ADPCM)
  µLaw
  aLaw

您可以打包在音频数据
  AIFF,WAV或CAF文件。

You can package the audio data in an aiff, wav, or caf file.

这篇关于设置为本地通知声音在3G版iPhone上运行iOS4的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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