关于为什么本地通知无法正常触发有很多问题here and there,还有几个关于为什么当应用程序处于后台状态时本地通知不会触发的问题,我也经历过them.
但令我惊讶的是,我没有找到任何与前台状态或活动状态相关的通知帖子,即在我的应用程序中,我面临这个奇怪的问题,即当应用程序进入后台模式时,本地通知会触发,而当应用程序处于活动状态或前台模式时,它不会触发,再次令我惊讶的是,即使为通知设置的触发日期已过期,进入后台后,通知也会立即触发。
EDIT
我面临的另一个问题是警报没有触发,即我们在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:@"[email protected]"];
[imageView setImage:image];
[alertView addSubview:imageView];
[imageView release];
[alertView show];
[alertView release];
}
抱歉,如果这个问题不需要在 stackoverflow 中提问或发帖。
任何人请发表您的建议,我们非常感谢任何帮助!
预先感谢大家:)
如果应用程序处于活动状态,那么您将不会收到任何声音、徽章或警报,但是应用程序委托application:didReceiveLocalNotification:
将被称为
From 苹果文档
当系统交付时,应用程序是否处于最重要且可见的位置
通知,不显示警报,没有图标标记,并且没有声音
玩过的。但是,应用程序:didReceiveLocalNotification:是
如果应用程序委托实现它,则调用。这
UILocalNotification 实例被传递到此方法中,并且
委托可以检查其属性或访问任何自定义数据
用户信息字典。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)