2012-02-13 10 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方法で私は再びこの曲を再生すると、それはいいですね。 は誰かは問題で私を助けることができます。ありがとう

P.S.私はwavの持続時間は30秒以上でなければならず、それは22秒であるので、それは再生すべきであることを読んでいる P.S.2地元の通知が鳴ったときに曲を再生する方法ですか?アプリのターゲットのプロパティでRequired background modesApp plays audioを持っている場合THANKS

答えて

0

をチェック。

+0

はい。私はそれを持っている。しかし、それはUILocalNotificationDefaultSoundName'は大丈夫働く '場合 –

+0

チェックを動作しません。そうであれば、あなたのサウンドを準備する必要があります。 '/ usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}'のように 'afcvert'を使って' .caf'に変換します。 –

関連する問題