> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-sdk-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Push Handled by Application

<Info>
  **SDK Version**

  * **General Messaging:** Supported from version 9.13.0
  * **Background Updates (Self handled):** Supported from version 10.10.0
</Info>

## Track Notification Received

Call SDK's ***logNotificationReceived(withPayload: )*** function to track notification received impression as shown below.

<CodeGroup>
  ```swift Swift wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  MoEngageSDKMessaging.sharedInstance.logNotificationReceived(withPayload:notification.request.content.userInfo) {
      // updated content in contentHandler here 
  }
  ```

  ```objective-c Objective C wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  [[MoEngageSDKMessaging sharedInstance] logNotificationReceivedWithPayload:notification.request.content.userInfo completion: ^(void) {
      // updated content in contentHandler here
  }];
  ```
</CodeGroup>

## Track Notification Click

To track the notification clicked event using the payload, call the SDK's ***logNotificationClicked*** function, as shown below.

<CodeGroup>
  ```swift Swift wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  MoEngageSDKMessaging.sharedInstance.logNotificationClicked(withPayload: notification.request.content.userInfo)
  ```

  ```objective-c Objective C wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  [[MoEngageSDKMessaging sharedInstance] logNotificationClickedWithPayload:notification.request.content.userInfo];
  ```
</CodeGroup>

To accurately track clicks or dismissals, use the ***logNotificationClicked(withResponse: )*** method.

<CodeGroup>
  ```swift Swift wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  MoEngageSDKMessaging.sharedInstance.logNotificationClicked(withResponse: UNNotificationResponse)
  ```
</CodeGroup>

<Note>
  **Note**

  To use above functions, Appdelegate swizzling should be disabled. To see how to disable swizzling, please see the [link](/developer-guide/ios-sdk/push/basic/ios-push-integration-tutorial#app-delegate-method-swizzling).
</Note>

## Validate if the notification belongs to MoEngage

Call SDK's ***isPushFromMoEngage(withPayload:)*** function to validate if the notification belongs to MoEngage as shown below:

<CodeGroup>
  ```swift Swift wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
   let isPushFromMoEngage = MoEngageSDKMessaging.sharedInstance.isPushFromMoEngage(withPayload: notification.request.content.userInfo))
  ```

  ```objective-c Objective C wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  BOOL isPushFromMoEngage = [[MoEngageSDKMessaging sharedInstance] isPushFromMoEngageWithPayload:notification.request.content.userInfo];
  ```
</CodeGroup>

## Handling Background Updates (Self-Handled)

<Note>
  **Prerequisites for iOS Background Updates**

  * **Background Modes:** You must enable **Remote notifications** under the *Signing & Capabilities* tab in Xcode.
  * **Payload Identifier:** The SDK identifies these payloads by checking for `nt: sh_b` inside the `moeFeatures` dictionary.
</Note>

The **Background Update** template allows you to send silent data payloads to your application. Because these notifications do not display a UI, the MoEngage SDK provides a specific helper method to identify them so you can execute custom background logic.

For more information on the payload structure and available keys, refer to [Background Update Templates](https://help.moengage.com/hc/en-us/articles/4415622460948-Push-Templates).

<Info>
  **Implementation Note**

  Background updates must be handled in the `didReceiveRemoteNotification` fetch completion handler. You must also call `logNotificationReceived` manually to ensure these silent events are recorded in your analytics.
</Info>

<CodeGroup>
  ```swift Swift wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

  // 1. Check if it's a MoEngage Background Update payload
  if MoEngageSDKMessaging.sharedInstance.isSelfHandledBackgroundNotification(payload: userInfo) {
      
      // 2. Log notification received impression manually
      MoEngageSDKMessaging.sharedInstance.logNotificationReceived(withPayload: userInfo) {
          
          // 3. Execute your custom background logic here (e.g., sync data, logout)
          // self.handleCustomBackgroundLogic(userInfo)
          
          // 4. Always call the completion handler
          completionHandler(.newData)
      }
  } else {
      // Handle standard MoEngage or other push notifications
      MoEngageSDKMessaging.sharedInstance.didReceieveNotification(inApplication: application, withInfo: userInfo)
  }


  }
  ```

  ```objective-c Objective C wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

  // 1. Check if it's a MoEngage Background Update payload
  if ([[MoEngageSDKMessaging sharedInstance] isSelfHandledBackgroundNotificationWithPayload:userInfo]) {
      
      // 2. Log notification received impression manually
      [[MoEngageSDKMessaging sharedInstance] logNotificationReceivedWithPayload:userInfo completion:^{
          
          // 3. Execute your custom background logic here (e.g., sync data, logout)
          // [self handleCustomBackgroundLogic:userInfo];
          
          // 4. Always call the completion handler
          completionHandler(UIBackgroundFetchResultNewData);
      }];
  } else {
      // Handle standard MoEngage or other push notifications
      [[MoEngageSDKMessaging sharedInstance] didReceieveNotificationInApplication:application withInfo:userInfo];
  }


  }
  ```
</CodeGroup>
