iOS 8 [UIApplication sharedApplication].scheduledLocalNotifications 空 [英] iOS 8 [UIApplication sharedApplication].scheduledLocalNotifications empty

查看:13
本文介绍了iOS 8 [UIApplication sharedApplication].scheduledLocalNotifications 空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用更新到 iOS 8.在一个函数中,我以这种方式安排了一个本地通知(我已经检查了 firedate 和通知的所有其他部分是否正确):

i'm trying to update my app to iOS 8. In a function i schedule a local notification (i've already checked that firedate and all other parts of the notification are right) in this way:

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

然后我使用此代码打印预定的本地通知:

then i use this code to print the scheduled local notification:

NSLog(@"notifications %@", [UIApplication sharedApplication].scheduledLocalNotifications );

但是数组

[UIApplication sharedApplication].scheduledLocalNotifications 

即使没有触发通知也是空的.然后,为了检查本地通知是否真的被安排,我尝试使用代码

is empty even if the notification is not fired. Then , to check if the local notification is really scheduled, i tried to use the code

NSLog(@"notification appdelegate %@", application.scheduledLocalNotifications );

在函数中

- (void)applicationWillResignActive:(UIApplication *)application 

of Appdelegate.m 在这种情况下,调度的本地通知数组不为空,NSLog 函数打印正确的通知.这仅发生在真实设备上,在模拟器中我的应用程序运行良好.问题不在于检查用户安排本地通知的权限,因为我已经遇到过.有人可以帮助我吗?一些想法?

of Appdelegate.m in this case, the array of the scheduled local notifications is not empty and the NSLog function print the correct notification. This happens only on real devices, in the simulator my app works fine. And the problem is not to check the permission of the user to schedule local notifications, cause i've already faced it. Could someone help me? some ideas?

推荐答案

这不是 iOS 8 的问题,而是

This is not iOS 8 issue, but

[UIApplication sharedApplication].scheduledLocalNotifications

问题.我在此处

现在有类似的问题.我的猜测是 iOS 没有立即安排通知,但仅在结束时当前运行循环.我在设置时遇到了这些问题scheduleLocalNotifications 属性在同一次运行中多次循环和更改似乎没有相应更新.我想我会自己保留一份本地通知数组的副本,然后只设置scheduleLocalNotifications 并且从不阅读它.

Having similar issues right now. My guess here is that iOS does not schedule the notifications immediately but only at the end of the current run loop. I am running into these problems when setting the scheduledLocalNotifications property several times in the same run loop and changes don't seem to be updated accordingly. I think I will just keep a copy of the local notifications array myself and only set scheduledLocalNotifications and never read it.

这篇关于iOS 8 [UIApplication sharedApplication].scheduledLocalNotifications 空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆