Tag: 时间表

如何在iOS(ObjC)中安排每日本地推送通知?

无法以正确的方式安排每日本地PushNotification 。 我想在上午9:00只显示一个每日本地推送通知,并计算今天的任务。 我的代码在didFinishLaunchingWithOptions只执行一次,如: – (void)scheduleLocalNotification { self.localNotification = [UILocalNotification new]; unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:unitFlags fromDate:[NSDate date]]; components.hour = 9; components.minute = 0; components.second = 0; NSDate *fireTime = [calendar dateFromComponents:components]; _localNotification.fireDate = fireTime; _localNotification.alertBody = [NSString stringWithFormat:@"Hi, <username>. You have […]