iOS 8 [UIApplication sharedApplication].scheduledLocalNotifications empty

后端 未结 4 1548
悲哀的现实
悲哀的现实 2020-12-11 06:04

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)

4条回答
  •  既然无缘
    2020-12-11 06:26

    I am facing same issue and Finally I got solution why its happened.

    if your are not set fireDate in notification object. its work perfect but when you are try to get notification list its always blank.

    here is notification object without set fire date

    {fire date = (null), time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Tuesday, September 5, 2017 at 3:31:44 PM India Standard Time, user info = (null)}
    

    here is notification object with fire date

    {fire date = Tuesday, September 5, 2017 at 3:35:17 PM India Standard Time, time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = 0, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Tuesday, September 5, 2017 at 3:35:17 PM India Standard Time, user info = (null)}
    

    here is code you can comment fire date and check its different

        let localNotification = UILocalNotification()
         **//Comment ..firedate and test it**
        localNotification.fireDate = NSDate(timeIntervalSinceNow: 5)
        localNotification.alertBody = "new Blog Posted at iOScreator.com"
        localNotification.timeZone = NSTimeZone.defaultTimeZone()
        localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
         UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
    
        print(localNotification)
    
       for notification in   UIApplication.sharedApplication().scheduledLocalNotifications! as [UILocalNotification] {
    
            print(notification)
    
        }
    

提交回复
热议问题