Skip to content

Instantly share code, notes, and snippets.

@seyhunak
Created July 16, 2014 14:47
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seyhunak/b4fa0722d5b7d44437c6 to your computer and use it in GitHub Desktop.
Save seyhunak/b4fa0722d5b7d44437c6 to your computer and use it in GitHub Desktop.
Local Notification - Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Override point for customization after application launch.
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert |
UIUserNotificationType.Badge, categories: nil))
return true
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
let notification: UILocalNotification = UILocalNotification()
notification.timeZone = NSTimeZone.defaultTimeZone()
let dateTime = NSDate()
notification.fireDate = dateTime
notification.alertBody = "Woww it works!!"
notification.alertAction = "Testing notifications on iOS8"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment