> ## 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.

# Notification Content Extension が実装されていない場合に iOS プッシュ通知（SDK バージョン 9.x.x）でプッシュテンプレートの問題を回避するには

> MoEngage iOS プロジェクトで Notification Content Extension をセットアップして、SDK 9.x.x での iOS プッシュテンプレートの問題（カルーセル、色、フォント）を修正します。

## 問題

Notification Content Extension が実装されていない場合、プッシュテンプレート（カルーセル画像、背景色、フォントの色など）がプッシュ通知で正しく表示されません。

## 手順

次の手順を実行します。

1. Notification Content Extension ターゲットを作成します。

   ![NCE.png](https://mintcdn.com/moengage/0iWkm50wROjmHH3Z/images/moengage_d10ae6.png?fit=max\&auto=format\&n=0iWkm50wROjmHH3Z\&q=85\&s=1d4c9db6cb35be19fbd9b64a47db846a)
   * *Extension ターゲットに名前を付けます。* Extension ターゲットの名前を選択します。**Swift** は Objective-C プロジェクトでもシームレスに動作するため、言語として推奨されます。 ![name swift.png](https://mintcdn.com/moengage/rcvpxihxIp--_HSE/images/moengage_911e54.png?fit=max\&auto=format\&n=rcvpxihxIp--_HSE\&q=85\&s=57b91079910c270488d2fe5fc4037568)
   * Notification Content Extension の **Signing & Capabilities** 設定に **AppGroupId** を追加します。

     ![signing.png](https://mintcdn.com/moengage/DUgG020WbtkVK2Ls/images/moengage_340deb.png?fit=max\&auto=format\&n=DUgG020WbtkVK2Ls\&q=85\&s=bc5f8a06d4271b0c19a94ff66de66851)
   * Notification Content Extension の最小デプロイ iOS バージョンをメインアプリの iOS バージョンに合わせて設定します。

     ![deployment.png](https://mintcdn.com/moengage/xaH8HoR16_YVDek5/images/moengage_cf2e7a.png?fit=max\&auto=format\&n=xaH8HoR16_YVDek5\&q=85\&s=6daa42d5797879a3cff2b8ddbfa0890b)
2. *MORichNotification フレームワークを Notification Content Extension ターゲットに統合します。*
   * podfile で Notification Content Extension を別のターゲットとして追加し、**MORichNotification** フレームワークをインストールします。
     ```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. **NotificationViewController.swift** ファイルのコード変更。
   ```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()
           MoEngageSDKRichNotification.setAppGroupID("group.com.XXXXXXXXXXXXXXXX")
       }
       
       func didReceive(_ notification: UNNotification) {
           if #available(iOSApplicationExtension 12.0, *) {
               MoEngageSDKRichNotification.addPushTemplate(toController: self, withNotification: notification) 
           } else {
               // Fallback on earlier versions
           }
       }
   }
   ```
4. Content Extension で **MainInterface.storyboard** を選択し、デフォルトのラベルを削除して、View の背景色を透明（clear）に設定します。

![main.png](https://mintcdn.com/moengage/SBG7um9Fqotw1CFo/images/moengage_b62459.png?fit=max\&auto=format\&n=SBG7um9Fqotw1CFo\&q=85\&s=c9cc78a5a0effa77701b4267c0e60abf)

5. Info.plist の変更：
   ```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>
   ```
   ![NSExtension.png](https://mintcdn.com/moengage/t_8awpRKFC9RNHlT/images/moengage_aaf96d.png?fit=max\&auto=format\&n=t_8awpRKFC9RNHlT\&q=85\&s=c21809c3c833092d8eec0a2ea1d348c9)
6. *メインアプリターゲットの Build Phases を確認します。*
   * Embed App Extensions/Embed Foundation Extensions で、**Copy only when installing** が選択されていないことを確認します。 ![copy only.png](https://mintcdn.com/moengage/BlcsVkkZu61NB-XQ/images/moengage_48edea.png?fit=max\&auto=format\&n=BlcsVkkZu61NB-XQ\&q=85\&s=4e7b8672672ed87c0549e37fbf17b29f)
7. *構成間で appGroupId を統一します。*
   * プロジェクト内のすべてのスキームと構成（例：Debug/Release/QA/UAT）で **appGroupId** が一致していることを確認します。
8. *ビルド構成を揃えます。*
   * プロジェクトを実行またはアーカイブする際は、メインターゲット、Notification Service Extension、Notification Content Extension ターゲットの Build Configuration が同じスキーム/構成を指していることを確認します。 ![debug.png](https://mintcdn.com/moengage/8EX_gHAg3q4zA1kw/images/moengage_26e08d.png?fit=max\&auto=format\&n=8EX_gHAg3q4zA1kw\&q=85\&s=d7214b9de5d9d5aae3ae2e7f4a450d89) ![target.png](https://mintcdn.com/moengage/2kQqTYC5RUPSd8kI/images/moengage_3ed4ee.png?fit=max\&auto=format\&n=2kQqTYC5RUPSd8kI\&q=85\&s=9426c230a45466113acde4575f71c3f2) ![duplicate.png](https://mintcdn.com/moengage/xjBZUVmmH3jDrySH/images/moengage_c6b4f5.png?fit=max\&auto=format\&n=xjBZUVmmH3jDrySH\&q=85\&s=cd3f99393872036b1cfb2059372dd218)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.