【问题标题】:Scheduler UILocalNotification is not working when app is on the foreground using ios 8当应用程序使用 ios 8 在前台时,调度程序 UILocalNotification 不起作用
【发布时间】:2015-09-04 06:21:20
【问题描述】:

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

开火日期 = 2015 年 9 月 4 日星期五下午 6:28:37 印度标准 时间,时区 = 亚洲/加尔各答 (GMT+5:30) 偏移 19800,重复 间隔 = 0,重复计数 = UILocalNotificationInfiniteRepeatCount, 下一次开火日期 = (null), 用户信息 = (null)

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

【问题讨论】:

    标签: ios objective-c ios8 uilocalnotification


    【解决方案1】:

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

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

    在日志中我得到了

    收到:{触发日期 = 2015 年 9 月 4 日星期五下午 12:25:44 印度标准时间,时区 = 亚洲/加尔各答 (GMT+5:30) 偏移 19800,重复间隔 = 0,重复计数 = UILocalNotificationInfiniteRepeatCount, 下一次触发日期 = (null), 用户信息 = { a = ab; }}

    【讨论】:

    • 我知道当应用程序处于前台时 didReceiveLocalNotification 会调用,您的代码很好,但我的问题不同,您是否检查了我的示例代码
    • 谢谢,但在执行此通知后,前台无法正常工作
    • @nivritgupta 它正在前台工作。日志在应用程序处于前台时。也许你犯了一些错误。在didReceiveLocalNotification中写NSLog(@"Received: %@",[thisNotification description]);
    • 我知道你的代码很好。但是如果您检查演示代码 .. 通知警报视图仅在应用程序在后台时工作,但是当应用程序在前台时 UILocalNotification 警报视图不工作
    • @nivritgupta 您必须添加警报代码。该库没有添加警报代码。你必须自己添加代码。那个库不会做任何事情。我们必须自己定制
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 2020-10-22
    相关资源
    最近更新 更多