我必须根据UILocalNotification
和hours
的特定日期触发minutes
,但没有date
。例如。我必须在每个“UILocalNotification
”上触发Mon 02:30 PM
。如何设置这样的本地通知?
请建议我。
谢谢!
答案 0 :(得分:1)
您可以将UILocalNotification的repeatInterval
设置为NSCalendarUnitWeekday
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
UILocalNotification *notification=[[UILocalNotification alloc] init];
NSDate *currentDate = [NSDate date];
notification.fireDate = [currentDate dateByAddingTimeInterval:10.0];
notification.repeatInterval = NSCalendarUnitWeekday;
notification.alertBody = @"Wake up, man";
notification.soundName= UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber++;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
答案 1 :(得分:1)
从当前日期获取下一个星期一日期。为此,请点击此链接Next Monday Date
之后为其设置for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
print eth
并将notification
设置为repeat interval
,以便通知将在每个星期一触发。
答案 2 :(得分:0)
您将获得系统日期和时间,并使用它来设置逻辑。
在伪代码中:
if today == monday {
if time == 2:30 PM {
fire local notification .
}
}