> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-analytics-query-api-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Avoid Push Template Issues in iOS Push Notifications (SDK version 8.x.x) When Notification Content Extension is Not Implemented?

> Fix iOS push template issues (carousel, colors, fonts) on SDK 8.x.x by implementing a Notification Content Extension for your MoEngage project.

## Problem

Push templates (carousel images, background color, font color, and so on) do not display correctly in Push notifications when the Notification Content Extension is not implemented.

## Instruction

Perform the following steps:

1. Create a Notification Content Extension Target.

<img src="https://mintcdn.com/moengage-analytics-query-api-docs/DPmJojzt83dkElsC/images/moengage_381db3.png?fit=max&auto=format&n=DPmJojzt83dkElsC&q=85&s=f3121d39ab201d18037f26059795323d" alt="NCE.png" width="1454" height="1040" data-path="images/moengage_381db3.png" />

* *Name the Extension Target.* Choose a name for the extension target. **Swift** is recommended as the language as it works seamlessly with Objective-C projects too.
  <img alt="name swift.png" src="https://mintcdn.com/moengage-analytics-query-api-docs/1Fw7DR1fWSnG2ZgE/images/moengage_6dbf7c.png?fit=max&auto=format&n=1Fw7DR1fWSnG2ZgE&q=85&s=8205ae5df52d0b3931f351ffcbcf588b" width="1412" height="1016" data-path="images/moengage_6dbf7c.png" />
* Add the **AppGroupId** to the Notification Content Extension’s **Signing & Capabilities** settings. <img alt="signing.png" src="https://mintcdn.com/moengage-analytics-query-api-docs/MeUdCPw1UK4cXHEf/images/moengage_cfae58.png?fit=max&auto=format&n=MeUdCPw1UK4cXHEf&q=85&s=56e33aabd2509159d9349e632b126dc4" width="2560" height="836" data-path="images/moengage_cfae58.png" />
* Set the minimum deployment iOS version of the Notification Content Extension to match the main app’s iOS version.
  <img alt="deployment.png" src="https://mintcdn.com/moengage-analytics-query-api-docs/KRb62n5Kc9i9KaRq/images/moengage_1c1516.png?fit=max&auto=format&n=KRb62n5Kc9i9KaRq&q=85&s=3a688d6c3d89193ff9d37fcb58f15e7f" width="1920" height="455" data-path="images/moengage_1c1516.png" />

2. *Integrate the MORichNotification Framework into the Notification Content Extension Target.*
   * In your podfile, add the Notification Content Extension as a separate target and install the **MORichNotification** framework.
     ```swift Swift theme={null}
     target 'MoEngageDemo' do
       use_frameworks!
       pod 'MoEngage-iOS-SDK'
     end
     target 'MoEngageNotificationService' do
       use_frameworks! #use use_frameworks only if included in main target as in above scenario
       pod 'MoEngageRichNotification'
     end
     target 'MoegageRichContent" do
       use_frameworks! #use use_frameworks only if included in main target as in above scenario
       pod 'MoEngageRichNotification'
     end
     ```
3. Code changes in **NotificationViewController.swift** file.
   ```swift Swift theme={null}
   import UIKit
   import UserNotifications
   import UserNotificationsUI
   import MoEngageRichNotification
   class NotificationViewController: UIViewController, UNNotificationContentExtension {
       @IBOutlet var label: UILabel?
       
       override func viewDidLoad() {
           super.viewDidLoad()
           MORichNotification.setAppGroupID("group.com.XXXXXXXXXXXXXXXX")
       }
       
       func didReceive(_ notification: UNNotification) {
           if #available(iOSApplicationExtension 12.0, *) {
               MORichNotification.addPushTemplate(toController: self, withNotification: notification) 
           } else {
               // Fallback on earlier versions
           }
       }
   }
   ```
4. Select **MainInterface.storyboard** in the Content extension, remove the default label, and set the background color of the View to clear.
   <img alt="main.png" src="https://mintcdn.com/moengage-analytics-query-api-docs/1Fw7DR1fWSnG2ZgE/images/moengage_6c5271.png?fit=max&auto=format&n=1Fw7DR1fWSnG2ZgE&q=85&s=fd046dca3f0a4bbb0961860c98d71713" width="3360" height="1646" data-path="images/moengage_6c5271.png" />
5. Info.plist changes:
   ```swift Swift theme={null}
   <key>NSExtensionAttributes</key> 
   <dict>
         <key>UNNotificationExtensionCategory</key>
         <string>MOE_PUSH_TEMPLATE</string>
         <key>UNNotificationExtensionDefaultContentHidden</key>
         <true/>
         <key>UNNotificationExtensionInitialContentSizeRatio</key>
         <real>1.2</real>
         <key>UNNotificationExtensionUserInteractionEnabled</key>
         <true/>
   </dict>
   ```
   <img src="https://mintcdn.com/moengage-analytics-query-api-docs/ctBTwn9sDIr0LbBo/images/moengage_8c6d4d.png?fit=max&auto=format&n=ctBTwn9sDIr0LbBo&q=85&s=c561f37c3f9b6b55938299c165573b2d" alt="NSExtension.png" width="1948" height="786" data-path="images/moengage_8c6d4d.png" />
6. *Check Build Phases in Main App Target.*
   * In Embed App Extensions/Embed Foundation Extensions, ensure that **Copy only when installing** is not selected.
     <img alt="copy only.png" src="https://mintcdn.com/moengage-analytics-query-api-docs/eYSmjDAzPiwzb39P/images/moengage_241f44.png?fit=max&auto=format&n=eYSmjDAzPiwzb39P&q=85&s=d1c267245213f22204dcc2f4d0a11604" width="2740" height="930" data-path="images/moengage_241f44.png" />
7. *Ensure Consistent appGroupId Across Configurations.*
   * Verify that the **appGroupId** is consistent across all schemes and configurations (for example, Debug/Release/QA/UAT) in the project.
8. *Align Build Configuration.*

   * When running or archiving the project, make sure that the Build Configuration for the Main Target, Notification Service Extension, and Notification Content Extension Target points to the same scheme/configuration.
     <img src="https://mintcdn.com/moengage-analytics-query-api-docs/xmBTezCZOP5Q8cSU/images/moengage_e1336f.png?fit=max&auto=format&n=xmBTezCZOP5Q8cSU&q=85&s=98400ffc7cb500cc2c0fded5451281d3" alt="debug.png" width="1750" height="556" data-path="images/moengage_e1336f.png" />

   <img src="https://mintcdn.com/moengage-analytics-query-api-docs/nZu1UfmK3xhnLqhR/images/moengage_585502.png?fit=max&auto=format&n=nZu1UfmK3xhnLqhR&q=85&s=20ecac0415ff7cc573ce3bfee1026105" alt="target.png" width="1832" height="446" data-path="images/moengage_585502.png" />

   <img src="https://mintcdn.com/moengage-analytics-query-api-docs/8GscUheGMO8Wf0AE/images/moengage_2f8b4e.png?fit=max&auto=format&n=8GscUheGMO8Wf0AE&q=85&s=9f69200680cd9a0789955a4ec2a58c70" alt="duplicate.png" width="1826" height="976" data-path="images/moengage_2f8b4e.png" />
