Push templates

Notification Content Extension allows you to customize the appearance of the notification in expanded mode.For info on how to create campaigns with templates in the dashboard refer to this link.




Make sure you have completed the App Target and Notification Service Extension Implementation for supporting Rich Push in your project before proceeding with the below steps.


To support these custom push templates, your project needs to have a Notification Content Extension. Follow the below steps to create a Content Extension and to set it up to support MoEngage templates:

1. Create a Notification Content Extension

Screenshot 2024-02-05 at 1.09.00 PM.png

After the target is created, Activate the scheme for Extension when prompted for the same.

Screenshot 2024-02-05 at 1.09.40 PM.png

After this, your extension will be added to the project you will see a class with the extension name provided by you while creating and an .plist file associated with it.

2. Set deployment target 

Set the deployment target same as the main app target.

3. Add required Capabilities

In the Capabilities Section add App Groups and select the same app group id that you have configured in your App target and Notification Service Extension target.

Screenshot 2024-02-06 at 3.41.10 PM.png

Refer to the Set AppGroup ID section of the doc for more information on setting the app group ID on the main target

4. Info.plist changes

Screenshot 2024-02-07 at 10.54.36 AM.png

Make the changes in the Info.plist of your Notification Content Extension, as shown above, set NSExtensionAttributes as following:

Attribute Attribute Value
UNNotificationExtensionCategory MOE_PUSH_TEMPLATE
UNNotificationExtensionInitialContentSizeRatio 1.2
UNNotificationExtensionDefaultContentHidden YES
UNNotificationExtensionUserInteractionEnabled YES


  • Update the UNNotificationExtensionCategory with the necessary values according to the categories that you have declared.

5. Storyboard changes

Select MainInterface.storyboard in your Content extension and remove the default label which is placed there and set the background color of the view to clear color, as shown:

Screenshot 2024-02-07 at 10.48.41 AM.png

6. MoEngageRichNotification Integration

Integration via CocoaPod

For integrating through CocoaPod, include MoEngageRichNotification pod for your Notification Content Extension as shown below, and run the pod update / install command :

target "NotificationContent" do
	pod 'MoEngageRichNotification','~>7.16.0'

Integration via Swift Package Manager

For integrating through SPM, use the https://github.com/moengage/MoEngage-iOS-RichNotification.git GitHub URL link and set the branch as master or required version. 


Manual Integration

  • To integrate the MoEngageRichNotification SDK manually to your project follow this doc.

  • Add MoEngageRichNotification to embed binaries in the App target, and ensure it is linked to your Notification Content Extension target.

7. Code Changes in Content Extension:

Swift Objective-C
import UIKit
import UserNotifications
import UserNotificationsUI
import MoEngageRichNotification
class NotificationViewController: UIViewController, UNNotificationContentExtension {
    override func viewDidLoad() {
        // Set App Group ID
        MoEngageSDKRichNotification.setAppGroupID("Your App Group ID")
    func didReceive(_ notification: UNNotification) {
        // Method to add template to UI
        MoEngageSDKRichNotification.addPushTemplate(toController: self, withNotification: notification)

As shown above, make these changes in your NotificationViewController  class:

  1. Set the same App Group ID in viewDidLoad() method which was enabled in Capabilities.
  2. Call addPushTemplate(toController:withNotification:) method to add template in didReceiveNotification() callback.



Was this article helpful?
0 out of 2 found this helpful

How can we improve this article?