Created
July 16, 2014 14:47
-
-
Save seyhunak/b4fa0722d5b7d44437c6 to your computer and use it in GitHub Desktop.
Local Notification - Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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