安排本地通知时iPhone应用程序崩溃

时间:2016-04-26 17:59:51

标签: ios iphone swift localnotification

我正在使用下面给出的代码安排本地通知。我发布了应用程序,并且在安排本地通知(使用xCode崩溃报告计算出来)时,它很少会在少数用户的iPhone(占总用户数的10%)上使用。

 let now = NSDate()


                let tomorrow = now.dateByAddingTimeInterval(24 * 60 * 60)

                let dateFormatter = NSDateFormatter()
                dateFormatter.dateFormat = "yyyy-MM-dd"
                dateFormatter.timeZone = NSTimeZone.defaultTimeZone()
                let tDate = dateFormatter.stringFromDate(tomorrow)
                let strFireDate = tDate + " 22:00:00"


                dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

                if let fireDate = dateFormatter.dateFromString(strFireDate)
                {
                    localNotification.fireDate = fireDate

                }




                localNotification.repeatInterval = NSCalendarUnit.Day


            }

           if #available(iOS 8.2, *) {
               localNotification.alertTitle = "Some Text"
           } else {
               // Fallback on earlier versions
           }
            localNotification.alertBody = "Some Text."

            //localNotification.applicationIconBadgeNumber = 1
            UIApplication.sharedApplication().scheduleLocalNotification(localNotification)

0 个答案:

没有答案