> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-doc-2315-external-css-font-urls.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Avoid Common Push Notification Issues on iOS Devices Using iOS Objective C version 9.x.x?

> Troubleshoot push impression and image rendering problems on iOS with Objective-C SDK 9.x.x. Ensure appgroupid is set correctly in MoEngage.

## Problem

Common issues with Push notifications, including Push Campaign impressions not being tracked and images not rendering even though Push notifications are successfully delivered to device with Objective C version 9.x.x.

<Info>
  For Push Campaign impressions to be tracked, verify that the **Show iOS impressions** toggle on the MoEngage dashboard is turned on.

  <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/VkgGMsGmJgjZHMEB/images/moengage_1d2e81.png?fit=max&auto=format&n=VkgGMsGmJgjZHMEB&q=85&s=d764c7cad3ffb8f95ba6a053fdbc671c" alt="iOS imp.png" width="2744" height="1582" data-path="images/moengage_1d2e81.png" />
</Info>

## Solution

Perform the following steps:

1. **Check for app\_group\_id in your project’s main target for each configuration**: You can add the same app\_group\_id or different ones across configurations.
   <Info>
     Issues may arise if your configurations use different Bundle Identifiers but share the same app\_group\_id. Specifically, the Notification Service Extension may fail if two apps with different Bundle Identifiers but the same app\_group\_id are installed on the same device.
     To avoid this, you can use the same app\_group\_id across multiple configurations, but be aware that you won't be able to test all apps simultaneously on a single device.
   </Info>
   <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/CMGIayyAehQUvnLL/images/moengage_83496a.png?fit=max&auto=format&n=CMGIayyAehQUvnLL&q=85&s=4e7788eeb5a064c4b29aead676181530" alt="app group.png" width="1920" height="709" data-path="images/moengage_83496a.png" />
2. **Check for app\_group\_id during SDK initialization**:
   * If the SDK is initialized using info.plist, the APP\_GROUP\_ID key must be there inside the MoEngage key in your info.plist file.
   * If the SDK is initialized using sdkConfig, the APP\_GROUP\_ID must be in the sdkConfig variable inside the AppDelegate file.\
     **app\_group\_id in info.plist:**
     <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/Sj2TdxWgx0jz-aOK/images/moengage_98c1bf.png?fit=max&auto=format&n=Sj2TdxWgx0jz-aOK&q=85&s=d4cd80ebc1dd170253caa32213683b4f" alt="app id.png" width="1920" height="888" data-path="images/moengage_98c1bf.png" />
     **app\_group\_id in sdkConfig variable:**
   ```objective-c Objective-C wrap theme={null}
   MoEngageSDKConfig* sdkConfig = [[MoEngageSDKConfig alloc] initWithAppId:@"XXXXXXXXXXXXXXXX" dataCenter: MoEngageDataCenterData_center_0X];
   sdkConfig.appGroupID = @"group.com.XXXXXXXXXXXXXXXX";
   ```
3. **Check for a Notification Service Extension Target**:
   * **Enable Push Notifications**: In the extension target's Signing & Capabilities section, make sure to enable Push Notifications and add the AppGroupId.
     <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/ihIsaOZe9_SIMB6G/images/moengage_d0ceea.png?fit=max&auto=format&n=ihIsaOZe9_SIMB6G&q=85&s=19829145799f4f1d37ba9a87ee2db248" alt="enable.png" width="1920" height="706" data-path="images/moengage_d0ceea.png" />
   * **Align the Minimum Deployment iOS Version**: Ensure that the minimum deployment iOS version of the Notification Service Extension matches the iOS version of the main app. <img alt="support.png" src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/-f7p3goMVJ1esraQ/images/moengage_812799.png?fit=max&auto=format&n=-f7p3goMVJ1esraQ&q=85&s=bec121a552019663871f046c735d8072" width="1920" height="563" data-path="images/moengage_812799.png" />
4. Integrate the MORichNotification framework into the Notification Service Extension target.
   ```objective-c Objective-C 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
   ```
5. NotificationService.m file looks like this:
   ```objective-c Objective-C theme={null}
   #import "NotificationService.h"
   @import MoEngageRichNotification;
    
   @interface NotificationService ()
    
   @property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
   @property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
    
   @end
    
   @implementation NotificationService
    
   - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
       @try {
         	[MoEngageSDKRichNotification setAppGroupID: @"group.com.XXXXXXXXXXXXXXXX"];
           self.contentHandler = contentHandler;
           self.bestAttemptContent = [request.content mutableCopy];
           [MoEngageSDKRichNotification handleWithRichNotificationRequest:request withContentHandler:contentHandler];
       } @catch (NSException *exception) {
           NSLog(@"MoEngage : exception : %@",exception);
       }
   }
   /// Save the image to disk
   - (void)serviceExtensionTimeWillExpire {
       // Called just before the extension will be terminated by the system.
       // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
       self.contentHandler(self.bestAttemptContent);
   }
   @end
   ```
6. **Check Build Phases for the Main App Target**: In the Build Phases section of the main app target, locate the Embed App Extensions / Embed Foundation Extensions section. Ensure that the **Copy only when installing** option is unchecked.
   <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/ni6bb-Qu12fJTRQv/images/moengage_fabafa.png?fit=max&auto=format&n=ni6bb-Qu12fJTRQv&q=85&s=e45bbc36a0270f94f6a881985acc3831" alt="copy.png" width="1920" height="652" data-path="images/moengage_fabafa.png" />
7. **Ensure Consistent appGroupId Across Configurations**: Verify that the appGroupId is consistent across all schemes and configurations (e.g. Debug/Release/QA/UAT) in the project.
8. **Align Build Configuration**: When running or archiving the project, ensure that the Build Configuration for the Main Target and Notification Service Extension Target points to the same scheme/configuration.
   <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/BcxFJ_SrYyTriZXT/images/moengage_11ca3c.png?fit=max&auto=format&n=BcxFJ_SrYyTriZXT&q=85&s=7b8e7fc49d8e27c247b74c92e74c5705" alt="run.png" width="1750" height="556" data-path="images/moengage_11ca3c.png" />
   <img src="https://mintcdn.com/moengage-doc-2315-external-css-font-urls/sPQr3K-d1ig5R-he/images/moengage_9fd89d.png?fit=max&auto=format&n=sPQr3K-d1ig5R-he&q=85&s=e65615acc312fef825d4335cc72ddf7d" alt="build.png" width="1832" height="446" data-path="images/moengage_9fd89d.png" />
