是否可以在定时后设置uilocalnotification的alert body
我遇到了 UILocalNotifications 的问题。我的问题是——是否可以在安排后设置 uilocalnotification 的警报正文?
提前致谢。
-------------------------------------
// scheduling uilocalnotification
localNotification = [[UILocalNotification alloc]init];
NSDate *currDate1 = [defaults objectForKey:@"Default_AlarmTime"];
localNotification.fireDate = currDate1;
localNotification.alertBody = @"Alarm";
localNotification.alertAction = @"View";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatInterval = NSWeekdayCalendarUnit;
[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];
// changing alert body of existing local notification
Arr=[[UIApplication sharedApplication]scheduledLocalNotifications];
for (int k=0;k<[Arr count];k++)
{
localNotification = [Arr objectAtIndex:k];
NSLog(@"%@",localNotification.fireDate);
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeZone:[NSTimeZone defaultTimeZone]];
[dateFormat setDateFormat:@"hh:mma"];
dateString = [dateFormat stringFromDate:localNotification.fireDate];
NSLog(@"%@",dateString);
currDate = [defaults objectForKey:@"Default_AlarmTime"];
NSLog(@"%@",currDate);
if ([currDate isEqualToString:dateString])
{
localNotification.alertBody = @"Haiiiiii";
}
}
---------------------------
I'm facing an issue with UILocalNotifications. my question is-- Is it possible to set the alert body of uilocalnotification after it is scheduled ??
thanks in advance.
-------------------------------------
// scheduling uilocalnotification
localNotification = [[UILocalNotification alloc]init];
NSDate *currDate1 = [defaults objectForKey:@"Default_AlarmTime"];
localNotification.fireDate = currDate1;
localNotification.alertBody = @"Alarm";
localNotification.alertAction = @"View";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.repeatInterval = NSWeekdayCalendarUnit;
[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];
// changing alert body of existing local notification
Arr=[[UIApplication sharedApplication]scheduledLocalNotifications];
for (int k=0;k<[Arr count];k++)
{
localNotification = [Arr objectAtIndex:k];
NSLog(@"%@",localNotification.fireDate);
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeZone:[NSTimeZone defaultTimeZone]];
[dateFormat setDateFormat:@"hh:mma"];
dateString = [dateFormat stringFromDate:localNotification.fireDate];
NSLog(@"%@",dateString);
currDate = [defaults objectForKey:@"Default_AlarmTime"];
NSLog(@"%@",currDate);
if ([currDate isEqualToString:dateString])
{
localNotification.alertBody = @"Haiiiiii";
}
}
---------------------------
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,这是不可能的。要更改已安排的通知,您必须取消并完全重新安排它。
As far as I know, this is not possible. To change an already scheduled notification, you have to cancel and completely reschedule it.