是否可以在显示NSLocalNotification之前和安排之后修改NSLocalNotification的警报正文?

时间:2015-07-13 09:46:22

标签: ios8 scheduling uilocalnotification

这是我的代码,用于安排 UILocalNotificaiton 并每分钟重复一次:

UILocalNotification *localNotification = [[UILocalNotification alloc] init];

localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:delay];
localNotification.alertAction = nil;
localNotification.soundName = UILocalNotificationDefaultSoundName;

localNotification.alertBody = @"Initial message";
localNotification.alertAction = NSLocalizedString(@"Return to App", nil);
localNotification.repeatInterval = NSCalendarUnitMinute;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

通知触发后,我想更改警报正文(标题等)以反映此通知被触发的次数。

这是我的代码:

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
{
    notif.soundName = UILocalNotificationDefaultSoundName;
    notif.alertBody = @"Changing body"; //This is where I will put the count
}

然而,身体不会改变。

1 个答案:

答案 0 :(得分:0)

不要记得,但它不包含setAlertBody方法吗?