相关疑难解决方法(0)

UILocalNotification无法正常工作

这是我的代码.我必须为localNotification添加任何内容.有什么建议.提前致谢.我阅读了很多本地通知教程.我不知道错过了什么.

var localNotifications : UILocalNotification!

    func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {

        localNotifications  = UILocalNotification()
        localNotifications.fireDate = NSDate(timeIntervalSinceNow: 20)
        localNotifications.timeZone = NSTimeZone.defaultTimeZone()
        localNotifications.alertBody = "Check it out!"
        localNotifications.soundName = UILocalNotificationDefaultSoundName
        localNotifications.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
        UIApplication.sharedApplication().scheduleLocalNotification(localNotifications)
Run Code Online (Sandbox Code Playgroud)

}

 func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {

        println("Alvin Notification recieved")

        if application.applicationState == UIApplicationState.Active
        {
            // show alertView

            Utilities.sharedInstance.alertThis("Hello", message: "Hey")
        }
        else if application.applicationState == UIApplicationState.Background
        {
            UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
        }
        else if application.applicationState == UIApplicationState.Inactive
        {
            UIApplication.sharedApplication().presentLocalNotificationNow(localNotifications)
        }

        application.applicationIconBadgeNumber = 0 …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ipad ios swift

0
推荐指数
1
解决办法
2352
查看次数

标签 统计

ios ×1

ipad ×1

iphone ×1

swift ×1

xcode ×1