我想将 a 的重复间隔自定义为UILocalNotification
一周中的某些天。我还没有找到任何有关此的信息。
如何对一周中某些天的通知重复间隔进行编程,例如,在星期日、星期一和星期五重复通知?
我想将 a 的重复间隔自定义为UILocalNotification
一周中的某些天。我还没有找到任何有关此的信息。
如何对一周中某些天的通知重复间隔进行编程,例如,在星期日、星期一和星期五重复通知?
不幸的是,您不能将repeatInterval
属性设置UILocalNotification
为仅在特定日期重复。您可以设置每天(每天)、每月(每个月)或每小时(每小时)重复。因此,对于您的问题,唯一可行的解决方案是,如果您想在周日、周一和周二设置闹钟,那么您必须设置 3 个闹钟(周日、周一和周二各一个)而不是一个闹钟。
如果您需要自定义repeatInterval
属性。您必须UILocalNotification
在指定时间设置每个。这是我的代码。
void (^insertAlarm)(NSDate*fire,NSString*sound,int alarmCount) = ^(NSDate*fire,NSString*sound,int alarmCount){
UILocalNotification* notification = [[UILocalNotification alloc] init];
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.soundName = sound;
notification.fireDate = fire;
notification.repeatInterval = 0;
notification.alertLaunchImage = IMG;
notification.alertAction = ACTION_MSG;
notification.alertBody = BODY;
notification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release];
};
insertAlarm(date,sound.fileName,0);
insertAlarm([date dateByAddingTimeInterval:60],sound.fileName,1);