我发布了一个本地通知警报(iOS 5),它将定期(每分钟)重复其提醒,直到用户通过在 UILocalNotification
实例上设置 repeatInterval
来确认它为止 [[UIApplication sharedApplication] scheduleLocalNotification:
设置'repeatInterval'的效果是每次重复通知而不确认通知时,通知中心会有另一个条目 . 例如:在没有开火的5分钟后,通知中心有5个单独的条目 .
有没有办法只有一个条目,但声音/振动警报每1分钟?
以下是我创建本地通知的方式:
UILocalNotification *localNotify = [[UILocalNotification alloc] init];
localNotify.fireDate = aFireDate;
localNotify.timeZone = [NSTimeZone defaultTimeZone];
localNotify.userInfo = userInfo;
// 3. Configure the substance of the notification: alert, icon badge number, and sound.
localNotify.alertBody = NSLocalizedString(alertTitleText, nil);
localNotify.alertAction = NSLocalizedString(alertActionText, nil);
localNotify.soundName = UILocalNotificationDefaultSoundName;
localNotify.applicationIconBadgeNumber = 1;
localNotify.repeatInterval = NSMinuteCalendarUnit;
// Schedule the local notification for delivery.
[[UIApplication sharedApplication] scheduleLocalNotification:localNotify];
1 回答
很不幸的是,不行 . 只要用户为您的应用启用了通知中心,您触发的每个本地通知都会在通知中心中显示为不同的条目;即使它们是同一个UILocalNotification对象的多次发射 . UILocalNotification API让你无法控制它 .