2017-01-16 1 views
0

iOS 목표 c에서 알람 기본 프로젝트를 진행 중입니다. 응용 프로그램이 백그라운드에있을 때 경보로 UILocalnotification을 구현했습니다. 하지만 내가 직면하고있는 문제는 소리가 30 초 동안 만 재생된다는 것입니다.알람 응용 프로그램에 대한 UILocalnotification이 30 초 이상

어떻게 사운드의 시간 간격을 늘리거나 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 초 동안 울립니다. 제 생각에 이것은 표준 행동입니다

Apple 지침에 따라 30 초 동안 mp3 파일을 사용해야합니다. 아래 링크를 확인하십시오.

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

주 : 참고로, UILocalNotification이 iOS10에서 사용되지 않습니다. UNUserNotificationCenter를 사용해야합니다.

+0

알림 이외의 다른 알람 기능을 구현하는 다른 방법이 있습니까? 알림은 5 초 또는 30 초 동안 재생되기 때문에. 반면 예상 결과는 60 초 이상 지속되어야합니다. –

+0

두 개의 로컬 알림을 설정하지 않으면이 작업을 수행 할 수 없습니다. iOS의 알람 앱은 30 초 이상 사운드를 재생할 수있는 특별한 권한이 있습니다. you.http : //stackoverflow.com/questions/9445090/alarm-clock-app-in-ios에 도움이 될만한 링크를 확인하십시오. – miOS

관련 문제