ios - 当应用程序在前台使用 ios 8 时,调度程序 UILocalNotification 不工作

标签 ios objective-c ios8 uilocalnotification

UILocalNotification 未触发当应用程序处于前台模式时,但相同的代码在应用程序处于后台时工作正常,从日志中获取此信息时,用户信息始终为 Null该应用程序处于前台模式。

fire date = Friday, September 4, 2015 at 6:28:37 PM India Standard Time, time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = (null), user info = (null)

请检查此示例代码,我正在我的应用程序中使用此代码 example code

最佳答案

您是否在触发通知时设置了 UserInfo?在示例代码中,它是 nil。检查我是否设置了 userinfo = andInfo:@{@"a":@"ab"}

[[MKLocalNotificationsScheduler sharedInstance] scheduleNotificationOn:[NSDate dateWithTimeIntervalSinceNow:10]
                                                                  text:@"Hey there" 
                                                                action:@"View" 
                                                                 sound:nil 
                                                           launchImage:nil 
                                                               andInfo:@{@"a":@"ab"}];

在日志中我得到

Received: {fire date = Friday, September 4, 2015 at 12:25:44 PM India Standard Time, time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = (null), user info = { a = ab; }}

关于ios - 当应用程序在前台使用 ios 8 时,调度程序 UILocalNotification 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32391345/

相关文章:

ios - collectionView.collectionViewLayout.invalidateLayout()

iphone - 格式化包含以逗号分隔的数字的字符串

ios - PGMidi更改音高sendBytes示例

ios8 - NSItemProvider 到 uiimage 或 alasset 等照片格式

ios - 想要将时间戳添加到居中对齐 textview 并将标签调整为右对齐

php - 创建网站的移动快捷方式

objective-c - 调用 [[.. alloc] init] 时丢失对象

ios - NSURLSession 是否支持 FTP 上传?

ios - 使用 presentViewController 方法在另一个 VC 中设置属性

url - 如何获取刚刚添加到 PHPhotoLibrary 中的图像的 URL