UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]];
[localNotification setAlertAction:@"Launch"];
[localNotification setAlertBody:[alertBodyField text]];
[localNotification setHasAction: YES];
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[alertNotification setHidden:NO];
问问题
226 次
2 回答
0
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3600]];
[localNotification setAlertAction:@"Launch"];
[localNotification setAlertBody:[alertBodyField text]];
[localNotification setHasAction: YES];
// change
localNotification.repeatInterval = NSWeekCalendarUnit; // set the repeat interval
localNotification.soundName = UILocalNotificationDefaultSoundName; // set alert sound
[localNotification setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[alertNotification setHidden:NO];
于 2013-03-02T12:13:44.760 回答
0
这里重复时间间隔列表:
指定日历单位,例如日和月。
enum {
NSEraCalendarUnit = kCFCalendarUnitEra,
NSYearCalendarUnit = kCFCalendarUnitYear,
NSMonthCalendarUnit = kCFCalendarUnitMonth,
NSDayCalendarUnit = kCFCalendarUnitDay,
NSHourCalendarUnit = kCFCalendarUnitHour,
NSMinuteCalendarUnit = kCFCalendarUnitMinute,
NSSecondCalendarUnit = kCFCalendarUnitSecond,
NSWeekCalendarUnit = kCFCalendarUnitWeek,
NSWeekdayCalendarUnit = kCFCalendarUnitWeekday,
NSWeekdayOrdinalCalendarUnit = kCFCalendarUnitWeekdayOrdinal,
NSQuarterCalendarUnit = kCFCalendarUnitQuarter,
NSWeekOfMonthCalendarUnit = kCFCalendarUnitWeekOfMonth,
NSWeekOfYearCalendarUnit = kCFCalendarUnitWeekOfYear,
NSYearForWeekOfYearCalendarUnit = kCFCalendarUnitYearForWeekOfYear
NSCalendarCalendarUnit = (1 << 20),
NSTimeZoneCalendarUnit = (1 << 21),
};
typedef NSUInteger NSCalendarUnit;
在您的情况下:
将重复间隔设置为'NSWeekCalendarUnit'
应该可以解决问题。它每周在与原始通知相同的日期和时间重复。
对于设置通知声音:
localNotification.soundName = UILocalNotificationDefaultSoundName; // Here you can also use custom sound .
对于自定义声音
localNotification.soundName = @"alarm_sound.wav";// put name of sound file
于 2013-03-02T12:08:35.557 回答