Skip to main content
This is the recommended way to add push notifications and VoIP calling to an iOS app. CometChatPushNotifications handles APNs and PushKit token registration, foreground presentation, notification taps, quick reply, campaign receipts, badge counts and the whole PushKit + CallKit incoming-call flow. You do not write a PKPushRegistry or a CXProviderDelegate.It works with or without the UI Kit. If you would rather wire APNs, PushKit and CallKit yourself, see iOS APNs Push Notifications.

Requirements

Install

In Xcode, File → Add Package Dependencies and add:
Pick version 1.0.0 or later, and add the CometChatPushNotificationsSwift library to your app target.
The module you import is CometChatPushNotificationsSwift, not CometChatPushNotifications. The latter is the name of the class inside it.

Before you start

  1. In the CometChat dashboard, enable Push Notifications and add your APNs credentials. Add an APNs Device provider and an APNs VoIP provider, and copy the Provider ID.
  2. In Xcode, add these capabilities to your app target:
    • Push Notifications
    • Background ModesVoice over IP and Remote notifications
  3. Add NSMicrophoneUsageDescription and NSCameraUsageDescription to your Info.plist — iOS terminates the app at the first call permission request without them.

1. Initialize

Call this after CometChat.init(...):
That single call requests notification permission, registers for remote and VoIP pushes, listens for login and logout to re-register and unregister tokens, and takes over UNUserNotificationCenter handling.
You do not call CometChatNotifications.registerPushToken(...) yourself. The SDK does it on every login, for both the APNs device token and the PushKit VoIP token.

2. Forward the APNs token

In your AppDelegate:
registerDeviceToken takes optional onSuccess / onError closures if you want the result.
The token can arrive before initialize(config:) runs. The SDK caches it and registers it automatically once you initialize and the user logs in, so ordering is not your problem.
That is the only AppDelegate code required. There is no PKPushRegistryDelegate and no CXProviderDelegate to write.

3. Implement the delegate

Every method has a default no-op implementation — override only what you need.

Cold start: tell the SDK when the Calls SDK is ready

A VoIP push can wake your app before your Calls SDK is ready. The SDK buffers the presentCallScreen callback until you tell it to release. Call notifyCallsSDKReady() once login has resolved — not merely when init succeeds:
Release it after login, not after init. notifyCallsSDKReady() only lifts the buffer — it does not check whether anyone is logged in. Calling it at init success releases the call while the session is still unauthenticated, and the joinSession that follows presentCallScreen fails on auth.
There is a 3-second safety timeout: if notifyCallsSDKReady() has not been called by then, the SDK fires the buffered presentCallScreen anyway so the call is never silently dropped. A cold start whose login takes longer than 3 seconds will therefore reach presentCallScreen before login completes — handle that in your call screen rather than assuming a live session.

Notification Service Extension

Adds delivery receipts, sender avatars, campaign images and markdown-free notification text.
1

Add the target

File → New → Target → Notification Service Extension.
2

Share an App Group

Add the same App Group (e.g. group.com.yourcompany.yourapp) to both the app target and the extension target, and pass it as extensionGroupID when you initialize.
3

Subclass the base class

Link CometChatPushNotificationsSwift to the extension target and replace the generated class:
4

Point the extension at the App Group

Add a String entry CometChatExtensionGroupID set to your App Group ID in the extension’s Info.plist, or override the extensionGroupID property instead.
Optional overrides: stripsMarkdown, attachesMedia, and finalizeContent(_:) for last-chance content customization.

Configuration reference

foregroundCallPresentation decides what happens when a call arrives while the app is open:

Other APIs

Testing checklist

  • Run on a physical device — VoIP pushes never reach the Simulator.
  • Confirm both providers exist in the dashboard and that providerId matches the one you passed.
  • Watch onPushTokenRegistrationFailed — a wrong Provider ID shows up here first.
  • Test an incoming call in all three states: foreground, background, and app terminated (cold start — this is what notifyCallsSDKReady() covers).

Push Notifications Overview

Dashboard setup, providers and templates.

Manual APNs + CallKit integration

The hand-wired alternative, if you need full control over PushKit and CallKit.

Calls: ringing

The in-app 1:1 call signaling this builds on.