每两周一次本地通知

时间:2014-08-07 05:55:08

标签: ios uilocalnotification

link1 link2

如果我想将本地通知设置为每2周重复一次而不是如何实现此目的?

我在这里已经阅读了几个问题和答案,他们提到了重新安排本地通知,但如何在申请处于后台时重新安排本地通知?

我将不胜感激任何帮助。

感谢。

1 个答案:

答案 0 :(得分:0)

要重新安排UILocal通知,请使用此

NSDateFormatter *dat= [[NSDateFormatter alloc]init];
[dat setLocale:[NSLocale currentLocale]];
[dat setTimeZone:[NSTimeZone systemTimeZone]];

//[dat setDateFormat:@"YYYY-MM-dd"];// YYYY-MM-dd hh:mm a
//NSString *dateM=[dat stringFromDate:datM];
//[dat setDateFormat:@"YYYY-MM-dd h:mm a"];
NSDate *reminderDate=[NSDate date];
//Use manual option too for timing    
reminderDate =[reminderDate dateByAddingTimeInterval:1*24*60*60*7];


UILocalNotification  *localnoification = [[UILocalNotification alloc]init];
localnoification.fireDate=reminderDate;
localnoification.timeZone = [NSTimeZone defaultTimeZone];
localnoification.alertBody = word;
localnoification.alertAction = @"Tap to see word of the day";
//May Add Custom Sound Also
//localnoification.soundName = UILocalNotificationDefaultSoundName;

localnoification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

//localnoification.applicationIconBadgeNumber = 1;
localnoification.repeatInterval = NSDayCalendarUnit;

[[UIApplication sharedApplication] scheduleLocalNotification:localnoification];
相关问题