我正在努力在每天的某个时间点击本地通知(由用户设置)。我过去已经这样做了,但只是每天都会显示一条静态消息。我希望它能从我每行作为引用的plist文件中获取本地通知的文本。有没有办法解雇本地通知,但每天都要更改文本?
我现在:
- (IBAction)scheduleNotification {
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Today's 5 Minutes With God Study Is Now Available";
notif.alertAction = @"Ok";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
NSInteger index = [scheduleControl selectedSegmentIndex];
switch (index) {
case 0:
notif.repeatInterval = NSDayCalendarUnit;
break;
case 1:
notif.repeatInterval = 0;
break;
}
NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"Today's Quote!"
forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[self.notifications addObject:notif];
[notif release];
}
}
那么,我如何让alertBody每天显示不同的消息?
答案 0 :(得分:3)
您必须每次为每条新消息创建一个新通知。