Notification Content Extension 

Updated 4 October 2022

Save

Notification Content Extension is an extension to your app which provides a custom interface to your notification in the notification center.

Content extensions  provide a great user experience because they’re integrated with the notification center and it runs in a process independent of the main process. However, it is mandatory for the main application to receive feedback when displaying the content extension. In this blog, we will discuss how to create a content extension.

Create a Content Extension:

Add a Notification Content Extension target to your application by selecting File -> New -> Target, and then selecting the Notification Content Extension icon in the Application Extension section as follow:

The extension that is created contains a NotificationViewController that adheres to the UNNotificationContentExtension.

If a UIViewController inside a Notification Content Extension adheres to the UNNotificationContentExtension, we are able to access the notification content and we can customize its UI. In the extension, there’s a MainInterface.storyboard that contains a single controller associated with the NotificationViewController previously mentioned. We can use this storyboard to customize the notification UI using an interface builder.

We can change the UI with the notification contents we receive in func didReceive(_ notification: UNNotification).Your code will look like below:

Now we have to go back to our notification content extension and set some attributes in its info.plist. In particular, we have to set:

We’re ready to test our implementation. 

Conclusion:

That’s all for Notification Content App Extension on iOS. Let’s start to test them in your app. To read more of my blogs, please visit this link. Thank you for reading this blog.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home