gpt4 book ai didi

objective-c - UILocalNotification有时不通知我

转载 作者:行者123 更新时间:2023-12-01 16:53:52 24 4
gpt4 key购买 nike

在我的应用程序中,我每次打开应用程序时都会安排一些UILocalNotification,但是有时uilocalnotification不会被触发并且不通知我,并且当它们不再触发时,要修复它,我必须重新安装该应用程序iPhone,所以我很好地解释了一下,通知工作了一段时间,然后一天不工作了,要修复它,我必须重新安装它,因此要调查,我创建了这种方法当应用程序激活时被调用:

-(void)checkNotification {

for (UILocalNotification *someNotification in [[UIApplication sharedApplication] scheduledLocalNotifications]) {

NSLog(@"%@",someNotification.alertBody);
NSLog(@"%@",someNotification.fireDate);
}
}

而且我看到所有通知都已安排好,还有日期,这是一个示例:
2012-11-25 18:36:36.532 TestApp[672:907] This is a notification.
2012-11-25 18:36:37.482 TestApp[672:907] 2012-11-27 10:00:00 +0000

所以我不明白为什么我没有收到通知...任何帮助?

编辑:
我以这种方式创建通知:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = myNewDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"This is a notification.";
localNotification.soundName = @"smallBell.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

最佳答案

您可能会或可能不会收到警报消息。这取决于您的应用程序是否正在运行以及处于哪种状态,例如在前台处于 Activity 状态,在后台处于 Activity 状态或根本不运行。

请参阅本文以进行澄清-http://www.thekspace.com/home/component/content/article/62-uilocalnotification-demystified.html

关于objective-c - UILocalNotification有时不通知我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13553677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com