> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-analytics-query-api-docs.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 8.x.x?

> Fix push impression tracking and image rendering on iOS with Objective-C SDK 8.x.x. Verify appgroupid configuration in your MoEngage integration.

## 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 8.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-analytics-query-api-docs/-XUsdGsfvAL-nHf0/images/moengage_458274.png?fit=max&auto=format&n=-XUsdGsfvAL-nHf0&q=85&s=b146d75357455c9db3ff921d0f4bf963" alt="iOS imp.png" width="2744" height="1582" data-path="images/moengage_458274.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-analytics-query-api-docs/VA7EbWABunFQ0gfA/images/moengage_d35dec.png?fit=max&auto=format&n=VA7EbWABunFQ0gfA&q=85&s=4ddf6f6068c085619db768ddfa97ddc4" alt="app group.png" width="1920" height="709" data-path="images/moengage_d35dec.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-analytics-query-api-docs/z39Dm5KCX2DtIPd9/images/moengage_b4b13a.png?fit=max&auto=format&n=z39Dm5KCX2DtIPd9&q=85&s=ac4d06f6d20fe19d7090389292effc62" alt="app id.png" width="1920" height="888" data-path="images/moengage_b4b13a.png" />
     **app\_group\_id in sdkConfig variable:**
   <CodeGroup>
     ```objective-c Objective-C wrap theme={null}
     MOSDKConfig\* sdkConfig = [[MOSDKConfig alloc] initWithAppID: @"XXXXXXXXXXXXXXXX"];
     sdkConfig.moeDataCenter = MODataCenterData\_center\_0X;
     sdkConfig.appGroupID = @"group.com.XXXXXXXXXXXXXXXX";
     ```
   </CodeGroup>
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-analytics-query-api-docs/hxK-zIlFnolb1ilr/images/moengage_82ff4d.png?fit=max&auto=format&n=hxK-zIlFnolb1ilr&q=85&s=4dfb12d861d2af1bc10cd0645320c503" alt="enable.png" width="1920" height="706" data-path="images/moengage_82ff4d.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-analytics-query-api-docs/h_14varmBpj2xk72/images/moengage_431d64.png?fit=max&auto=format&n=h_14varmBpj2xk72&q=85&s=35eafafe72db719eed713f99e5d2169e" width="1920" height="563" data-path="images/moengage_431d64.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 
   @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 {
         	[MORichNotification setAppGroupID: @"group.com.XXXXXXXXXXXXXXXX"];
           self.contentHandler = contentHandler;
           self.bestAttemptContent = [request.content mutableCopy];
           [MORichNotification 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-analytics-query-api-docs/xqg7J9GuW1XHY7Tk/images/moengage_9bb544.png?fit=max&auto=format&n=xqg7J9GuW1XHY7Tk&q=85&s=483a469b0e4092e0879f53dd685085fa" alt="copy.png" width="1920" height="652" data-path="images/moengage_9bb544.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-analytics-query-api-docs/nZu1UfmK3xhnLqhR/images/moengage_569a68.png?fit=max&auto=format&n=nZu1UfmK3xhnLqhR&q=85&s=62137cf1dca1f9bf108e83db58b1f822" alt="run.png" width="1750" height="556" data-path="images/moengage_569a68.png" />
   <img src="https://mintcdn.com/moengage-analytics-query-api-docs/dKEqeh2ILfSrPmB2/images/moengage_29f224.png?fit=max&auto=format&n=dKEqeh2ILfSrPmB2&q=85&s=8aad5a052277d18fd0a2ec9664c4b46c" alt="build.png" width="1832" height="446" data-path="images/moengage_29f224.png" />
