iOS 8 [UIApplication sharedApplication] .scheduledLocalNotifications为空

use*_*731 6 notifications objective-c ios uilocalnotification ios8

我正在尝试将我的应用程序更新到iOS 8.在一个功能中,我通过这种方式安排本地通知(我已经检查过该通知并且通知的所有其他部分都是正确的):

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
Run Code Online (Sandbox Code Playgroud)

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

NSLog(@"notifications %@", [UIApplication sharedApplication].scheduledLocalNotifications );
Run Code Online (Sandbox Code Playgroud)

但阵列

[UIApplication sharedApplication].scheduledLocalNotifications 
Run Code Online (Sandbox Code Playgroud)

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

NSLog(@"notification appdelegate %@", application.scheduledLocalNotifications );
Run Code Online (Sandbox Code Playgroud)

在功能中

- (void)applicationWillResignActive:(UIApplication *)application 
Run Code Online (Sandbox Code Playgroud)

Appdelegate.m在这种情况下,安排本地通知的数组不为空和NSLog的功能打印正确的通知.这只发生在真实设备上,在模拟器中我的应用程序工作正常.问题不是检查用户安排本地通知的权限,因为我已经面对它了.有人能帮助我吗?一些想法?

Max*_*kin 12

这不是iOS 8的问题,但是

[UIApplication sharedApplication].scheduledLocalNotifications
Run Code Online (Sandbox Code Playgroud)

问题.我在这里找到的最相关的答案

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