我想設置本地通知每週通知消息,安裝應用程序時通知消息將隨機化。如何使用隨機消息從當前日期開始每週設置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