# Handling notifications with image

When sending notification from user.com to the iOS mobile app you can specify an image url. In order to display it within the notification you need to use a dedicated method from UserSDK.

In the Notification Service Extension of your application you need to import the UserSDK and call fillNotificationContent method of NotificationExtensionHelper class.

In order to have UserSDK available for your Notification Service Extension you have to specify it in the Podfile like below:

platform :ios, '13.0'

use_frameworks!

target 'YourApp' do
	pod 'UserSDK'
end

target 'YourApp-notification-service' do
	pod 'UserSDK'
end

The main class of the Notification Service Extension using UserSDK to attach images from user.com originating notification could look like this:

import UserNotifications
import UserSDK


class NotificationService: UNNotificationServiceExtension {


    var contentHandler: ((UNNotificationContent) -> Void)?
    var bestAttemptContent: UNMutableNotificationContent?
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        
        NotificationExtensionHelper.shared.fillNotificationContent(bestAttemptContent, contentHandler: contentHandler)
    }
    
    override func serviceExtensionTimeWillExpire() {
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            contentHandler(bestAttemptContent)
        }
    }
}

This setup is sufficient for displaying images added to the notification as a thumbnail and in the expanded view upon force touching the notification.