> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/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/_fazdN5K6hQMBuV9/images/moengage_381db3.png?fit=max&auto=format&n=_fazdN5K6hQMBuV9&q=85&s=0fc985fa38de6280a616e4781a1dc461" 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/S2vOz7ciYYqlhjCf/images/moengage_6dbf7c.png?fit=max&auto=format&n=S2vOz7ciYYqlhjCf&q=85&s=5e245224750574529387283b1b1bb8b9" 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/xaH8HoR16_YVDek5/images/moengage_cfae58.png?fit=max&auto=format&n=xaH8HoR16_YVDek5&q=85&s=a3527f3f3816071f7c615e0d337905a5" 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/QVZKszouQuxXOzFr/images/moengage_1c1516.png?fit=max&auto=format&n=QVZKszouQuxXOzFr&q=85&s=c9223e4932dd28965fc3450a6b46a0ae" 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/S2vOz7ciYYqlhjCf/images/moengage_6c5271.png?fit=max&auto=format&n=S2vOz7ciYYqlhjCf&q=85&s=34b36b88e76bcafd3a7e0d5a3d1a2165" 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/431DqtwGIOyvyx6H/images/moengage_8c6d4d.png?fit=max&auto=format&n=431DqtwGIOyvyx6H&q=85&s=e6fe9803d52a0fadb808a7b73fd900ec" 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/8EX_gHAg3q4zA1kw/images/moengage_241f44.png?fit=max&auto=format&n=8EX_gHAg3q4zA1kw&q=85&s=d2aab1d20a5d0fe6004b9d5ae33d8a79" 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/wIFGWsQFEjsz2j4v/images/moengage_e1336f.png?fit=max&auto=format&n=wIFGWsQFEjsz2j4v&q=85&s=207b9b83a0aefc0eddef82b846173bce" alt="debug.png" width="1750" height="556" data-path="images/moengage_e1336f.png" />

   <img src="https://mintcdn.com/moengage/B1ZqBU-ISgaoSx_O/images/moengage_585502.png?fit=max&auto=format&n=B1ZqBU-ISgaoSx_O&q=85&s=04f1c8f7eed31ca9065b7a076e503e2d" alt="target.png" width="1832" height="446" data-path="images/moengage_585502.png" />

   <img src="https://mintcdn.com/moengage/eF2J43N9Ckga5Apm/images/moengage_2f8b4e.png?fit=max&auto=format&n=eF2J43N9Ckga5Apm&q=85&s=28643713cc01798320f29dfacf13201c" alt="duplicate.png" width="1826" height="976" data-path="images/moengage_2f8b4e.png" />
