2012-02-13 3 views
0

다음은 몇 가지 코드입니다.알람 iphone SDK 문제

UIApplication *app = [UIApplication sharedApplication]; 
    NSArray *oldNotifications = [app scheduledLocalNotifications]; 

    if ([oldNotifications count] > 0) [app cancelAllLocalNotifications]; 


    NSString *filePath = [DOCUMENTS stringByAppendingPathComponent:@"personal2.wav"]; 
    //NSLog(@"%@",filePath); 
    //filePath = [[NSBundle mainBundle] pathForResource:@"wolf" ofType:@"wav"]; 
    UILocalNotification *localNotif = [[UILocalNotification alloc]init]; 
    localNotif.fireDate = alarmPicker.date ; 
    localNotif.timeZone = [NSTimeZone localTimeZone]; 
    localNotif.alertBody = @"Alarm"; 
    localNotif.alertAction = @"View"; 
    localNotif.soundName = filePath; 
    localNotif.applicationIconBadgeNumber = 1; 
    //localNotif.repeatInterval = NSYearCalendarUnit; 

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

그래서 경고 만 표시되지만 wav를 재생하지 않습니다. 보기를 클릭하면 응용 프로그램이 시작되고 didReceiveLocalNotification 메서드에서이 노래를 다시 재생하면 소리가 잘 들립니다. 누군가 문제를 해결할 수 있습니까? 감사합니다

추신 wav의 지속 시간은 30 초보다 짧아야하며 22 초이므로 재생해야합니다. P.S.2 지방 알림이 실행되면 노래를 반복하는 방법입니까? 감사합니다.

답변

0

이 앱의 대상 속성에 Required background modes에 있는지 확인하십시오.

+0

예. 나는 가지고있다. 하지만 작동하지 않습니다. –

+0

'UILocalNotificationDefaultSoundName'이 제대로 작동하는지 확인하십시오. 만약 그렇다면, 소리를 준비 할 필요가 있습니다.'/ usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}'와 같이'afconvert'를 사용하여'.caf'로 변환하십시오. –