問題
プッシュテンプレート(カルーセル画像、背景色、フォント色など)は、通知コンテンツ拡張が実装されていない場合、プッシュ通知に正しく表示されません。
命令
次の手順を実行します。
-
通知コンテンツ拡張ターゲットを作成します。
- 製品名 ボックスに、拡張ターゲットの名前を入力します。
-
言語
リストで、言語をクリックします。
Swift
は、Objective-Cプロジェクトとシームレスに動作するため推奨される言語です。
-
署名と機能
タブで、通知コンテンツ拡張の設定に
AppGroupId
を追加します。
-
最小展開
の下で、通知コンテンツ拡張の最小展開iOSバージョンをメインアプリのiOSバージョンに一致させます。
-
Integrate the MORichNotification framework into the Notification Content Extension target.
-
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
-
-
コードの変更は
NotificationViewController.swift
ファイル。
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 } } }
-
MainInterface.storyboard
をコンテンツ拡張で選択し、デフォルトのラベルを削除し、ビューの背景色をクリアに設定します。
-
Info.plistの変更:
3469949 -
メインアプリターゲットのビルドフェーズを確認してください。
-
Embed App Extensions/Embed Foundation Extensionsで、
インストール時のみコピー
のチェックボックスをクリアします。
-
Embed App Extensions/Embed Foundation Extensionsで、
インストール時のみコピー
のチェックボックスをクリアします。
-
設定全体で一貫した appGroupId を確保してください。
- プロジェクト内のすべてのスキームと構成(例えば、Debug/Release/QA/UAT)で appGroupId が一貫していることを確認してください。
-
ビルド構成を整合させる。
- プロジェクトを実行またはアーカイブする際は、メインターゲット、通知サービス拡張、通知コンテンツ拡張のビルド構成が同じスキームまたは構成を指すようにしてください。