【发布时间】:2017-01-16 05:03:36
【问题描述】:
我正在开发 iOS 目标 c 中的警报基础项目。
当应用程序在后台时,我已经实现了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.
请指教。 谢谢
【问题讨论】:
-
您需要将该文件拆分为多个 30s 声音文件,并进行多个通知
-
@Tj3n 感谢您的回复。但我的 mp3 文件超过 30 秒。
标签: ios objective-c uilocalnotification repeatingalarm