iOS - UILocalNotification-每隔一天设置一次通知

时间:2014-06-15 16:46:24

标签: ios uilocalnotification

我想每隔一天设置一次本地通知(在NSDayCalendarUnit上进行乘法),我该如何实现?

到目前为止,我已经这样做了:

- (void)scheduleLocalNotication {

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

// Set the fire date/time
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];

localNotification.applicationIconBadgeNumber = 1;

// Setup alert notification
[localNotification setAlertAction:@"Open App"];
[localNotification setAlertBody:@"setAreltBody"];
[localNotification setAlertBody:@"You had set a Local Notification on this time"];

localNotification.soundName = UILocalNotificationDefaultSoundName;
[localNotification setHasAction:YES];

localNotification.repeatInterval = NSDayCalendarUnit;

UIApplication *app = [UIApplication sharedApplication];
[app scheduleLocalNotification:localNotification];

}

我可以更改此行:

localNotification.repeatInterval = NSDayCalendarUnit;

这样的事情:

localNotification.repeatInterval = NSDayCalendarUnit * 2;

我猜不是,因为NSDayCalendarUnit是typedef,所以我该怎么办呢?

提前10倍!

1 个答案:

答案 0 :(得分:0)

我认为使用repeatInterval的{​​{1}}属性是不可能的,原因与您已指出的相同,UILocalNotification枚举,因此您只能使用以下值: values

另一种选择是在循环中安排多个通知,并始终将24小时添加到上一个开火日期。