UILocalNotification 声音每隔一段时间播放一次
UILocalNotification sound plays every other time
每当我创建一个 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 秒长。
我做错了什么?
谢谢!
我修复了它,但不是通过做任何有意义的事情。我将代码更改为此并且有效:
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];
每当我创建一个 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 秒长。
我做错了什么?
谢谢!
我修复了它,但不是通过做任何有意义的事情。我将代码更改为此并且有效:
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];