ios - UIlocalnotification 每天安排 - 8 :00 - 12:00 and 16:00

标签 ios apple-push-notifications uilocalnotification

启用uilocalnotification 需要每天启用此通知计划,我没有得到,我为每个工作小时创建了 3 种不同的方法,但事实并非如此。

上午 8:00

凌晨 12:00

下午 4:00

-(void)Hour_08 {
    NSString *str = [NSString stringWithFormat: @"%@ 08:00", self.DayNow];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm"];
    NSDate *date = [dateFormatter dateFromString: str];

    UILocalNotification *OitoHorasNotification = [[UILocalNotification alloc]init];
    [OitoHorasNotification setFireDate:date];
    OitoHorasNotification.repeatInterval = NSDayCalendarUnit;
    [OitoHorasNotification setAlertBody:@"is now 08:00"];
    [[UIApplication sharedApplication]scheduleLocalNotification:OitoHorasNotification];

}

最佳答案

你看过this site了吗?因为它建议您使用 NSHourCalendarUnit 而不是 NSDayCalendarUnit 如果您在一整天后执行通知,就会出现这种情况。或者也许你整天都在执行通知,因此你的代码是正确的我会错过阅读你的问题

关于ios - UIlocalnotification 每天安排 - 8 :00 - 12:00 and 16:00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21174228/

相关文章:

ios - 如何区分两个本地通知

IOS分发证书灰显

ios - 开始 iPhone 开发

ios - 应用商店 : transferring an iOS app and app ID

iOS 8+ 远程通知功能始终启用

ios - iOS 中的通知操作后台获取?

ios - 缺少推送通知权利

ios - Phonegap + jQueryMobile + iOS上的PushNotifications

iphone - 只让本地通知出现一次

swift - 如何在非事件 watch 收到本地通知时触发触觉警报