【发布时间】:2012-06-28 12:46:57
【问题描述】:
关于为什么本地通知没有正确触发here和there有很多问题,还有一些关于为什么当应用程序处于后台状态时本地通知没有触发的问题,我也经历过them.
但令我惊讶的是,我没有找到任何与前台状态或活动状态相关的通知帖子,即在我的应用程序中,我遇到了这个奇怪的问题,即当应用程序进入后台模式时本地通知会触发,当应用程序处于活动状态或前台模式时它不会触发,再次令我惊讶的是,即使在为通知设置的触发日期过期后,进入后台后,通知也会立即触发.
编辑
我面临的另一个问题是警报没有触发,即我们在didReceive本地通知方法中写的警报动作,下面是实现代码:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
application.applicationIconBadgeNumber = 0;
NSString *reminderText = [notification.userInfo objectForKey:addViewController.textField.text];
[self.addViewController showReminder:reminderText];
}
这是另一个控制器中存在的 showReminder 方法,即:
//Notification alert
- (void)showReminder:(NSString *)text
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Reminder" message:text delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)];
UIImage *image= [UIImage imageNamed:@"icon@2x.png"];
[imageView setImage:image];
[alertView addSubview:imageView];
[imageView release];
[alertView show];
[alertView release];
}
抱歉,如果此问题不需要问题或在 stackoverflow 中发帖。
任何人请发表您的建议,我们很乐意提供任何帮助!
提前谢谢大家:)
【问题讨论】:
标签: iphone uilocalnotification foreground