我想设置本地通知每周通知消息,安装应用程序时通知消息将随机化。如何使用随机消息从当前日期开始每周设置Localnotification
// Notification Random Message Array
messgeArray = [NSMutableArray arrayWithObjects:@"Welcome",@"Hello",@"How about you",@"Good Day",nil];
//通知了每星期
NSDate *date = [NSDate date];
NSDate *oneDaynotification = [date dateByAddingTimeInterval:60*60*24*7];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
srand((unsigned)time(NULL));
localNotification.fireDate = oneDaynotification;
randomMessage = [messgeArray objectAtIndex:arc4random() % [notificationArray count]];
localNotification.alertBody = randomMessage;
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
后,我改变我的系统时间,我没有看到任何通知消息,任何一个可以建议我如何每周执行一个通知触发随机通知消息与它。
http://stackoverflow.com/questions/24874160/weekly-local-notification – user523234