每当我创建UILocalNotification并且它被触发时,自定义声音我只播放每隔一个实例。这只发生在我的iPhone 5s上的模拟器外部。
UILocalNotification* sessionEndNotification = [UILocalNotification new];
sessionEndNotification.fireDate = [self.dateAppMinimized dateByAddingTimeInterval:[self secondsLeft]];
sessionEndNotification.alertBody = @"Your session has finished. Remember to remain mindful through the rest of your day!";
sessionEndNotification.soundName = @"bell.caf";
[[UIApplication sharedApplication] scheduleLocalNotification:sessionEndNotification];
如果我将soundName更改为UILocalNotificationDefaultSoundName,则每次都有效。 bell.caf是8秒长。
我做错了什么?
谢谢!
答案 0 :(得分:0)
我修复了它,但没有做任何有意义的事情。我将代码更改为此,它可以工作:
UILocalNotification* sessionEndNotification = [UILocalNotification new];
sessionEndNotification.soundName = @"endMeditationBell.aif";
sessionEndNotification.hasAction = YES;
sessionEndNotification.fireDate = [self.dateAppMinimized dateByAddingTimeInterval:[self secondsLeft]];
sessionEndNotification.alertTitle = @"Session finished";
sessionEndNotification.alertBody = @"Your session has finished. Remember to remain mindful through the rest of your day!";
[[UIApplication sharedApplication] scheduleLocalNotification:sessionEndNotification];