5

在 iPhone 应用程序中,

我正在设置本地通知。

我正在设置自定义声音。

当通知到来时,我无法“听到”任何声音。甚至没有默认声音。

在我的 iPod touch 和我的设备中都没有。

任何机构可以帮助我找出原因?

非常感谢。

这是代码。

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

localNotification.fireDate=[dateFormat dateFromString:alarm_date];

localNotification.alertBody = @"Alarm.";

localNotification.soundName = [filePath lastPathComponent];

//localNotification.soundName =soundname; 
//UILocalNotificationDefaultSoundName;

localNotification.applicationIconBadgeNumber = 1;

localNotification.alertAction=@"Show";


[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

[localNotification release];

答案 得到了愚蠢的点:通知声音只有在您的应用程序处于后台或关闭时才会播放。对不起这个问题。不管怎样,谢谢。

4

2 回答 2

2

我想这对你来说已经够用了.......

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];

    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:5];

    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    localNotification.alertBody = @"You have long time to care your......";
    localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber]+1;
    localNotification.soundName = UILocalNotificationDefaultSoundName;
    localNotification.repeatInterval = kCFCalendarUnitMinute;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
    [localNotification release];
    localNotification = nil;
于 2012-08-29T06:44:57.063 回答
2

作为通知声音播放的声音应少于 30 秒

另一件事:

根据 Apple Developer Documentation,您需要使用“aiff”、“caf”或“wav”文件。

于 2012-08-29T06:56:08.183 回答