Skip to content

Instantly share code, notes, and snippets.

@GxocT
Created July 17, 2018 11:22
Show Gist options
  • Save GxocT/21444d7095ce167b2699451e0ab7d0d8 to your computer and use it in GitHub Desktop.
Save GxocT/21444d7095ce167b2699451e0ab7d0d8 to your computer and use it in GitHub Desktop.
UNUserNotificationCenter.current().getNotificationSettings {
(settings) in
guard settings.authorizationStatus == .authorized else { return }
let content = UNMutableNotificationContent()
content.title = "Cat Title"
content.subtitle = "Cat Subtitle"
content.body = "Cat Body"
content.sound = .default
content.categoryIdentifier = "category-simple"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false)
let uuid = UUID().uuidString
let request = UNNotificationRequest(identifier: uuid, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: {
(error) in
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment