If you want to customize the appearance of local and remote notifications, perform the following steps:
-
Create a
UNNotificationCategoryand add to theUNUserNotificationCentercategory:let newCategory = UNNotificationCategory(identifier: "newCategory", actions: [ action ], minimalActions: [ action ], intentIdentifiers: [], options: []) let center = UNUserNotificationCenter.current() center.setNotificationCategories([newCategory]) -
Create a UNNotificationContentExtension:

then use code or storyboard to customize your UIViewController.
- Add category to
UNNotificationContentExtension‘s plist:

4.Push Notification
Local Notification
Create a UNMutableNotificationContent and set the categoryIdentifier to “newCategory” which includes UNUserNotificationCenter‘s categories and UNNotificationContentExtension‘s plist:
let content = UNMutableNotificationContent()
content.title = ...
content.body = ...
content.categoryIdentifier = "newCategory"
let request = UNNotificationRequest.init(identifier: "newNotificationRequest", content: content, trigger: nil)
let center = UNUserNotificationCenter.current()
center.add(request)
Remote Notification
Set "mutable-content : 1" and "category : newCategory". Note that the category value is set to “newCategory” which matches what you previously added to UNUserNotificationCenter and UNNotificationContentExtensions plist.
Example:
{
"aps" : {
"alert" : {
"title" : "title",
"body" : "Your message Here"
},
"mutable-content" : "1",
"category" : "newCategory"
},
"otherCustomURL" : "http://www.xxx.jpg"
}
- Note: you need a device or simulator which supports 3DTouch, otherwise you can’t show a custom
UNNotificationContentExtensionviewcontroller.(In iOS10 Beta1, it`s not work. But now this work without 3d touch)
And … if you just want to show an image on a push notification displayed on the lock screen, you need to add UNNotificationAttachment:
let content = UNMutableNotificationContent()
content.title = ...
content.body = ...
content.categoryIdentifier = "newCategory"
let fileURL: URL = ... // your disk file url, support image, audio, movie
let attachement = try? UNNotificationAttachment(identifier: "attachment", url: fileURL, options: nil)
content.attachments = [attachement!]
let request = UNNotificationRequest.init(identifier: "newNotificationRequest", content: content, trigger: nil)
let center = UNUserNotificationCenter.current()
center.add(request)

For more detail feature,Demo