Extension for rich Push Notification - iOS 10.
iOS 10 gave us
UserNotifications.framework, the new API for local/remote notifications.
It offers viewing media attachments or responding to messages right from the notification.
Notification content consists of: title, subtitle, body and attachment. Attachment can contain images/gifs/videos up to 50 mb.
- In xCode
Navigatorwindow go to
Add New Target.
Notification Content Extensiontemplate:
- In your
info.plistfile set the identifier for
The value of this key is a string or an array of strings. Each string contains the identifier of a category declared by the app using the UNNotificationCategory class.
Number that represents the initial size of your view controller’s view expressed as a ratio of its height to its width.
When set to YES, the system displays only your custom view controller in the notification interface. When set to NO, the system displays the default notification content in addition to your view controller’s content.
The value of this key is a Boolean. When set to true, the system uses the title property of your view controller as the title of the notification. When set to false, the system sets the notification's title to the name of your app. If you do not specify this key, the default value is set to false.
- Create custom view in
- Add new
category keyand set its value to what we typed in the Info.plist (step 3):
Also check out the official API reference: https://developer.apple.com/reference/usernotificationsui/unnotificationcontentextension?utm_source=swifting.io&utm_medium=web&utm_campaign=blog%20post
Notification Content Extension
Why do we need it?
Content extension helps us to create custom user interface upon notification expanasion.
You use this framework to define an extension that receives the notification data and provides the corresponding visual representation. Your extension can also respond to custom actions associated with those notifications.