Skip to content

Instantly share code, notes, and snippets.

@RameshAran
Last active September 19, 2016 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RameshAran/38b350482b848ba88bc08c8de2998488 to your computer and use it in GitHub Desktop.
Save RameshAran/38b350482b848ba88bc08c8de2998488 to your computer and use it in GitHub Desktop.
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil)
content.sound = UNNotificationSound.default()
// Deliver the notification in five seconds.
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false)
let request = UNNotificationRequest.init(identifier: "notification_sample_2", content: content, trigger: trigger)
// Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request)
@RameshAran
Copy link
Author

Creating a simple local notification in Swift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment