Skip to content

Instantly share code, notes, and snippets.

@pgpt10
Created May 29, 2018 09:31
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 pgpt10/2794797c9407ad9c7533bc73b7c77a31 to your computer and use it in GitHub Desktop.
Save pgpt10/2794797c9407ad9c7533bc73b7c77a31 to your computer and use it in GitHub Desktop.
//Notification Content
let content = UNMutableNotificationContent()
content.title = "Invitation"
content.subtitle = "This is a Local Notification."
content.body = "You are invited."
content.categoryIdentifier = "INVITATION"
content.sound = UNNotificationSound.default()
//Notification Trigger - when the notification should be fired
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
//Notification Request
let request = UNNotificationRequest(identifier: "Anniversary", content: content, trigger: trigger)
//Scheduling the Notification
let center = UNUserNotificationCenter.current()
center.add(request) { (error) in
if let error = error
{
print(error.localizedDescription)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment