Skip to content

Instantly share code, notes, and snippets.

@janodev
Last active August 16, 2016 12:46
Show Gist options
  • Save janodev/afb59d04c406b1719dbcea313134636e to your computer and use it in GitHub Desktop.
Save janodev/afb59d04c406b1719dbcea313134636e to your computer and use it in GitHub Desktop.
Create a notification with an image attachment
let content = UNMutableNotificationContent()
content.title = "Will it rain?"
content.body = "It never rains in (Southern) California!"
content.sound = UNNotificationSound.default()
let url = URL(string: "https://67.media.tumblr.com/ab04c028a5244377a0ab96e73915e584/tumblr_nfn3ztLjxk1tq4of6o1_400.gif")
let attachment = try! UNNotificationAttachment(identifier: "image", url: url!, options: nil)
content.attachments = [attachment]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment