2017-01-16 11 views
0

私はiOSの目的cのアラームベースプロジェクトに取り組んでいます。 アプリケーションがバックグラウンドのときにアラームのためにUILocalnotificationを実装しました。 しかし、私が直面している問題は、音が30秒間しか再生されないということです。30秒以上のアラームアプリケーションのためのUILocalnotification

サウンドの時間間隔を増やすにはどうすればよいですか、またはUILocalnotificationの代わりにサウンドを実装する方法が他にありますか。

- (IBAction)Alert:(id)sender{ 

     NSDateFormatter *format = [[NSDateFormatter alloc] init]; 
     [format setDateFormat:@"yyyy-MM-dd"]; 
     //NSDate *date = [NSDate date]; 


     UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
     localNotif.fireDate =[NSDate dateWithTimeIntervalSinceNow:15]; 
     localNotif.timeZone = [NSTimeZone localTimeZone]; 
     localNotif.alertBody = @"Emergency"; 

     localNotif.alertAction = @"View"; 
     localNotif.soundName = @"police.mp3"; 
     localNotif.applicationIconBadgeNumber = 1; 
     localNotif.repeatInterval = NSYearCalendarUnit; 


     [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 

    } 


    Note : mp3 file i am using for UILocalnotification is of more that 60min duration. 

アドバイスをしてください。 ありがとう

+1

このファイルを複数の30音ファイルに分割し、複数の通知を行う必要があります。 – Tj3n

+0

@ Tj3n返信いただきありがとうございます。しかし私のmp3ファイルは30秒以上です。 –

答えて

1

デバイスがアクティブモードの場合、通知音は5秒間しか再生されません。デバイスがスリープモードの場合、通知は30秒間鳴ります。これは標準の動作です

アップルのガイドラインに従って、30秒間のmp3ファイルを使用する必要があります。以下のリンクをご確認ください。

https://developer.apple.com/reference/usernotifications/unnotificationsound

注:FYI、UILocalNotificationはiOS10から廃止されました。 UNUserNotificationCenterの使用を開始する必要があります。

+0

通知以外のアラーム機能を実装する別の方法はありますか?通知は5秒または30秒間しか再生されないためです。期待された結果は、それは60秒以上の間再生する必要がありますか? –

+0

2つのローカル通知を設定しない限り、これはできません。 iOSのアラームアプリは30秒以上の音を再生する特別な特権を持っています。 .you.http://stackoverflow.com/questions/9445090/alarm-clock-app-in-iosに役立つリンクを確認してください。 – miOS

関連する問題