我正在開發一個需要本地通知的應用程序。我有一個包含多個對象的文本數組,每天都需要觸發數組的每一個元素。 我在這方面面臨很多問題。每次只有一個通知應該從數組中被觸發。 幫我解決這個問題。如何在ios每天同時發佈隨機本地通知
UILocalNotification * notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDateOfNotification;
notification.timeZone = [NSTimeZone localTimeZone];
NSString *myString = SelectedAffirmationText;
NSArray *myArray = [myString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];
//NSString *StrForNotification=[myArray objectAtIndex:0];
for(int i=0;i<myArray.count;i++)
{
NSString *StrForNotification=[myArray objectAtIndex:i];
notification.alertBody = [NSString stringWithFormat: @"%@",StrForNotification];
}
notification.alertAction = @"go back";
NSDictionary *userDict = [NSDictionary dictionaryWithObjectsAndKeys:DateSelected, @"Date", TimeSelected, @"Time",SelectedAffirmationText,@"DataAffiramtion", nil];
notification.userInfo = userDict;
notification.repeatInterval= NSDayCalendarUnit;
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
添加一些你正在工作的代碼。 – Arun
@Arun通過它添加了代碼..go並提出了答案 –
試試這個鏈接這可能會幫助你[每天火災本地通知](http://stackoverflow.com/questions/13296190/local-notification-everyday-at -700am-not-notifying) – Arun