6.2.0 and MORichNotification version 4.0.0, push templates will be supported where you would be able to customize the way notification looks in expanded mode. This feature is supported iniOS 12.0 and above. For info on how to create campaigns with templates in the dashboard refer to this link.
iOS 15.0 UpdateWith iOS 15.0 update, we have released
MORichNotification version 5.2.0 where for iOS 15.0 and above we have updated the layout to show content at the top and media at bottom, to have it in line with the standard notification layout.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.
STEPS:
For supporting 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
2. Set deployment target and Add Required frameworks
Now set the deployment target to iOS 12.0 or above, since we support this feature from iOS 12.0. After that addUserNotifications.framework and UserNotificationsUI.framework in Frameworks and Libraries as shown:
3. Add required Capabilities
In Capabilities Section add App Groups and select the same app group id which you have configured in your App target and Notification Service Extension target.App Group ID RecommendationWe recommend having a separate App Group ID set for MoEngage with the format
group.{app bundle id}.MoEngage. And make sure the same app group id is enabled for all the targets where MoEngage is being used.4. Info.plist changes
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 |
5. Storyboard changes
SelectMainInterface.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:
6. MoEngageRichNotification Integration
Integration via CocoaPod
For integrating through CocoaPod, include MoEngageRichNotification pod for your Notification Content Extension as shown below, and run pod update / install command :Integration via Swift Package Manager
For integrating through SPM, use the following github url link and set the branch as master or version as 6.2.0 and above https://github.com/moengage/MoEngage-iOS-RichNotification.gitManual Integration
- To integrate the
MoEngageRichNotificationSDK manually to your project follow this doc. - Add
MoEngageRichNotificationto embedded binaries in the App target, and ensure it is linked to your Notification Content Extension target.
7. Code Changes in Content Extension:
NotificationViewController class:
- Set the same App Group ID in
viewDidLoad()method which was enabled in Capabilities.[Recommended: group.{app bundle id}.MoEngage] - Call
addPushTemplateToController:withNotification:method to add template indidReceiveNotification()callback.
8. Notification Click callback in App:
In the case of Simple Image Carousel notification, to know which slide was clicked by the user, make use ofMOMessagingDelegate to get notificationClicked(withScreenName: andKVPairs:) callback to get key-value pairs and screen name if set for the clicked slide. Refer to the example below, here we are registering for the callback in AppDelegate: