更新时间:2023-02-26 21:18:19
您可以在将来创建通知,当它被调用时取消所有以前的通知并重新安排,直到您满意为止.
You can create a notification in the future and when it gets called cancel all the previous ones and reschedule until you're satisfied.
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = body;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.fireDate = [NSDate new]; //<-Set the date here in 10seconds for example
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
然后在应用中 didReceiveLocalNotification:(UILocalNotification *)notification:
Then in application didReceiveLocalNotification:(UILocalNotification *)notification:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
application cancelAllLocalNotifications;
}