我怎样才能在一天内安排一次本地通知?

时间:2021-04-29 20:15:08

I currently have local notifications working on an application but they're working in the viewDidLoad method. That means that every time that the application launches, local notifications are being scheduled which is redundant.

我目前在应用程序上有本地通知,但他们正在使用viewDidLoad方法。这意味着每次应用程序启动时,都会调度本地通知,这是多余的。

So how can I only have local notifications only being scheduled once per day?

那么我怎样才能每天只安排一次本地通知?

For a little extra detail, I have three local notifications being scheduled every day at 8am, 1pm and 8pm but they're being scheduled every time the app launches.

对于一些额外的细节,我每天都会在上午8点,下午1点和晚上8点安排三个本地通知,但每次应用启动时都会安排这些通知。

Cheers

干杯

1 个解决方案

#1


0  

You can check what notifications are scheduled using [UIApplication sharedApplication] scheduledLocalNotifications. This returns an NSArray of UILocalNotifications, which you can then use in viewDidLoad to do the necessary checks.

您可以使用[UIApplication sharedApplication] scheduledLocalNotifications检查调度的通知。这将返回UILocalNotifications的NSArray,然后您可以在viewDidLoad中使用它来执行必要的检查。

#1


0  

You can check what notifications are scheduled using [UIApplication sharedApplication] scheduledLocalNotifications. This returns an NSArray of UILocalNotifications, which you can then use in viewDidLoad to do the necessary checks.

您可以使用[UIApplication sharedApplication] scheduledLocalNotifications检查调度的通知。这将返回UILocalNotifications的NSArray,然后您可以在viewDidLoad中使用它来执行必要的检查。