2011-02-14 178 views
0

我想设置alrms,所以我使用这段代码。alrm sound not works

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
    if (localNotif == nil) 
     return; 
    localNotif.fireDate = itemDate; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 

    localNotif.alertBody = @"Appointment"; 

    localNotif.alertAction = @"View"; 

    //localNotif.soundName = UILocalNotificationDefaultSoundName; 
    localNotif.soundName = @"Iphone_Alarm.mp3"; 
    //[email protected]"sound.mp3"; 
    localNotif.applicationIconBadgeNumber = 1; 

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

它显示警报但不播放声音,声音名称有正确的大小写和拼写。在设备上它也没有振动。

回答

1

尝试定义成MP3文件的完整路径:

localNotif.soundName = [[NSBundle mainBundle] pathForResource:@"Iphone_Alarm" ofType:@"mp3"]; 

不知道的振动虽然。

+0

任何设置此设备上的任何设置。我可以在模拟器上播放声音。 – Ishu 2011-02-14 05:19:48