Quick Reference for AI Agents & Developers
- Requires: UNNotificationServiceExtension target in your app
- Purpose: Mark messages delivered even when app is in background/terminated
- Implementation: Call
CometChat.markAsDelivered()in notification extension - Parse payload: Extract message ID, sender ID, receiver type from notification
- Related: Delivery & Read Receipts · Push Notifications
If you already have a Notification extension on your project then you can skip the first part of creating a new extension and use the one you have.
Setting up Notification extension
- Navigate to your project’s target section and click on the plus iOS

- Then Scroll down, select Notification Service Extension and click on the next.

- Give it a name and click finish

- Your notification service extension is ready now, you can see that in the target list. Now we will create app group for the extension. This app group will be needed to share user default between the main application and notification service extension.
- Click on the notification service extension name on the target list, then select Signing & Capabilities, then click on “+ Capability” from the top. Make sure All is selected besides it.

- Then search for App Group and click on it. You can see a section of the app group section must have been added on the ‘Signing & Capabilities’.

- Select any of the suggested app group ID or you can add your own ID by clicking on the plus icon. Till this step app group is added on the notification extension target and app group is selected.

- Now we will add the Capability of App Group on the main app’s target as well. Just repeat the same steps that you have done on the notification extension(from step 4). You have to select your main app from the target list, then as we did for the notification extension switch to ‘Signing & Capabilities’, then click on “+ Capability” from the top and select App Group.
- Then select the same group ID that you have selected on the notification extension target’s app group. If it is not there in the suggested IDs, then add it by clicking on the plus icon.
Make sure the app ID is exactly the same on both the notification extension target and the main app target.
- Lastly, add CometChatSDK in your notification extension target in the pod file.
- Swift
Code for Mark as read
- Firstly navigate to the cometchat initialization code on you project and add the group ID that you have selected on app groups on the AppSettingsBuilder.
- Swift
Sample Payload - AppSettings with Extension Group ID
Sample Payload - AppSettings with Extension Group ID
Configuration Parameters:
Important Notes:
- Now navigate to your notification extension named group that is been created And open its swift file.
- Then import CometChatSDK on that file and call these 2 functions on the didReceive(_ request: , withContentHandler: ) function.
- Swift
Sample Payload - markAsDelivered from Push Notification
Sample Payload - markAsDelivered from Push Notification
Method Signature:
Sample Push Notification Payload (userInfo):
Effect After Marking Delivered:
Sample Payload - Push Notification for User Message
Sample Payload - Push Notification for User Message
Complete userInfo Dictionary:
Sample Payload - Push Notification for Group Message
Sample Payload - Push Notification for Group Message
Complete userInfo Dictionary:
Sample Payload - When to Use markAsDelivered
Sample Payload - When to Use markAsDelivered
Usage Scenarios:
Prerequisites:

Run the main app target first and make sure you are receiving notifications there. And then run the notification extension target.