> ## 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 バージョン 7.x.x）でプッシュテンプレートの問題を回避するには

> Notification Content Extension を作成して、SDK 7.x.x での iOS プッシュテンプレートの表示の問題（カルーセル、色、フォント）を修正します。完全なセットアップガイドを掲載しています。

## 問題

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

## 手順

次の手順を実行します。

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

   ![NCE.png](https://mintcdn.com/moengage/7H2dU4CG2W0DQCPI/images/moengage_71e025.png?fit=max\&auto=format\&n=7H2dU4CG2W0DQCPI\&q=85\&s=24011ffbc24fcab230b8c1118b845001)
   * **Product Name** ボックスに Extension ターゲットの名前を入力します。
   * **Language** リストで言語をクリックします。**Swift** は Objective-C プロジェクトでもシームレスに動作するため、言語として推奨されます。

     ![name swift.png](https://mintcdn.com/moengage/DUgG020WbtkVK2Ls/images/moengage_35e6b6.png?fit=max\&auto=format\&n=DUgG020WbtkVK2Ls\&q=85\&s=b6a69136992e73ac7031d9ec7f9e0bb9)
   * **Signing & Capabilities** タブで、Notification Content Extension の設定に *AppGroupId* を追加します。

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

     ![deployment.png](https://mintcdn.com/moengage/epqsPEpMsGQCYy1r/images/moengage_5c1797.png?fit=max\&auto=format\&n=epqsPEpMsGQCYy1r\&q=85\&s=f2b7ea3dbef13e379a9fde8432679bed)
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 'MORichNotification'
     end
     target 'MoegageRichContent" do
       use_frameworks! #use use_frameworks only if included in main target as in above scenario
       pod 'MORichNotification'
     end
     ```
3. **NotificationViewController.swift** ファイルのコード変更。
   ```swift Swift theme={null}
   import UIKit
   import UserNotifications
   import UserNotificationsUI
   import MORichNotification
   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, *) {
               MOPushTemplateHandler.sharedInstance().addPushTemplate(to: self, with: notification)
           } else {
               // Fallback on earlier versions
           }
       }
   }
   ```
4. Content Extension で **MainInterface.storyboard** を選択し、デフォルトのラベルを削除して、View の背景色を透明（clear）に設定します。

   ![main.png](https://mintcdn.com/moengage/ncl4TtlD4tqnPefh/images/moengage_771662.png?fit=max\&auto=format\&n=ncl4TtlD4tqnPefh\&q=85\&s=e392579a0932e3b386297b67b8398554)
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/CaPmX0z_ys8cr0ms/images/moengage_054a69.png?fit=max\&auto=format\&n=CaPmX0z_ys8cr0ms\&q=85\&s=d9be0e1662856fb626bd41526815b5e4)
6. メインアプリターゲットの Build Phases を確認します。
   * Embed App Extensions/Embed Foundation Extensions で、**Copy only when installing** チェックボックスをオフにします。

     ![copy only.png](https://mintcdn.com/moengage/xeb_76Bworf1GG6P/images/moengage_968bdb.png?fit=max\&auto=format\&n=xeb_76Bworf1GG6P\&q=85\&s=84f71b89f176a52e5edb104e68e3c357)
7. 構成間で *appGroupId* を統一します。
   * プロジェクト内のすべてのスキームと構成（例：Debug/Release/QA/UAT）で *appGroupId* が一致していることを確認します。
8. ビルド構成を揃えます。
   * プロジェクトを実行またはアーカイブする際は、メインターゲット、Notification Service Extension、Notification Content Extension ターゲットのビルド構成が同じスキームまたは構成を指していることを確認します。

     ![debug.png](https://mintcdn.com/moengage/UX7SFw6G5JwoHWFq/images/moengage_62d0a0.png?fit=max\&auto=format\&n=UX7SFw6G5JwoHWFq\&q=85\&s=01c73f9724f0b1f7a2b5ab26a7b8ac18)
   ![target.png](https://mintcdn.com/moengage/ME-DtlELD2N8TrcF/images/moengage_c31f9e.png?fit=max\&auto=format\&n=ME-DtlELD2N8TrcF\&q=85\&s=343eac9f1b77b8a027dd1f508933a60a)

   ![duplicate.png](https://mintcdn.com/moengage/t9d2bz7zij1iE1iP/images/moengage_9ee69a.png?fit=max\&auto=format\&n=t9d2bz7zij1iE1iP\&q=85\&s=990fd7cd8849e77f115990b453af8589)


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