【发布时间】:2017-09-30 19:52:38
【问题描述】:
我正在开发一个需要本地通知的应用。我有一个包含多个对象的文本数组,我需要每天触发数组的每个元素。 我在这方面面临很多问题。每次只应从数组中触发一个通知。 帮我解决这个问题。
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 添加了代码..通过它并提出答案
-
试试这个链接这可能对你有帮助fire local notification per day
-
感谢您的回答,但这不是我正在寻找的解决方案。我每天重复的通知工作正常,但每次我需要更改通知的文本时,我得到的文本都是相同的
-
@RamanSrivastava 你有什么想法吗?我也被同一部分卡住了。
标签: ios objective-c iphone