This is my code.is there anything that i have to add for the localNotification.? Any suggestions. Thanks in advance. I read lots of local notification tutorials. I have no idea what is missed.
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
}