Notification Service Extension

  1. In Xcode, select File >> New >> Target and choose the Notification Service Extension template.
  1. Define a name for the Notification Service Extension as given below.

Objective C


Swift code

  1. Once the target is created, Activate the scheme for Extension when prompted for the same. After this your extension will be added to project you will see a class with the extension name provided by you while creation and .plist file associated with it.

Objective C


Swift code

  1. You can configure the plist via source code or editor.

Source Code

Right Click on Info.plist and click on Open as >> Source code.Add the following code in it.

<key>App Bundle identifier</key>
            <string>”Your App’s Project Identifier Name”</string>

Add the following keys with their required values.

Add a new row by going to the menu and clicking Editor > Add Item. Set a key App Bundle identifier as a String and set its value to your app’s Bundle Identifier.


Expand the NSExtension and add NSExtensionAttributes as Dictionary. Inside NSExtensionAttributes dictionary add two keys : UNNotificationExtensionDefaultContentHidden as Boolean, its value should be YES and UNNotificationExtensionInitialContentSizeRatio as Number, its value should be 0.7

  1. Go to Build Phase tab of your Notification Service Extension target and click on “+” sign under Link Binary With Libraries. Then, click on “Add Other…” from the promoted box and add the reference of our sdk .a file from your apps project folder (Don’t give reference to.a file from outside of your project).

In the Capabilities Tab Turn On App Groups and select the app group created previously in the beginning.


Example: we have previously created a app group named make sure this app group must be visible here and make it checked (Turned on).
Goto NotificationService.m file and update didReceiveRequestWithContentHandler delegate mehod as follows

-(void)didReceiveNotificationRequest: (UNNotificationRequest*)request
            withContentHandler: (void (^)(UNNotificationContent *))contentHandler {
                self.contentHandler = contentHandler;
                self.bestAttemptContent = [request.content mutableCopy];    
                [notifyvisitors LoadAttachmentWithRequest: request bestAttemptContent: self.bestAttemptContent
                withContentHandler:  self.contentHandler];
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {

        self.contentHandler = contentHandler

        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

notifyvisitors.LoadAttachmentWithRequest(request, bestAttemptContent: self!.bestAttemptContent, withContentHandler: self!.contentHandler)