我遇到了一些非常恼人的问题UILocalNotification
。
在完成一个我几乎完成的应用程序时,我注意到无论我尝试什么,我都无法让本地通知工作。
因此,我没有浪费时间,而是决定回归基础,看看我是否能让它们发挥作用。
我创建了一个新的基于 XCode 视图的应用程序,并替换-viewDidLoad
为:
- (void)viewDidLoad
{
UILocalNotification * theNotification = [[UILocalNotification alloc] init];
theNotification.alertBody = @"Alert text";
theNotification.alertAction = @"Ok";
theNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
[[UIApplication sharedApplication] scheduleLocalNotification:theNotification];
}
但是,这也没有任何作用。
我希望在启动应用程序 10 秒后看到通知,但什么也没有出现。
另外,我在我的 iPhone 和模拟器上都进行了测试。
我在这里错过了一些非常重要的东西吗?(我已经搜索了 Apple 文档,但找不到任何关于为什么会发生这种情况的信息)
谢谢