UILocalNotification funktioniert nicht richtig

Dies ist mein Code. Gibt es etwas, das ich für die localNotification hinzufügen muss? Irgendwelche Vorschläge. Danke im Voraus. Ich habe viele Tutorials zu lokalen Benachrichtigungen gelesen. Ich habe keine Ahnung, was übersehen wird.

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)

}

 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
    }

Antworten auf die Frage(4)

Ihre Antwort auf die Frage