Skip to main content

Before Getting Started

Overview

Clix leverages Firebase Cloud Messaging (FCM) to deliver notifications efficiently. The goal is to ensure a smooth integration process and reliable delivery of push notifications to your app users.

Environment

  • Xcode 16.2 or later
  • Cocoapods or Swift Package Manager
Make sure you’ve completed the Firebase setup.If the setup is complete, the following items should be in place.
  1. Make sure GoolgeServies-Info.plist is in your project directory.
  2. Upload the Service Account Key file to the Clix console.
Clix provides a Homebrew CLI for quick and easy setup. Use the install and doctor commands to automatically configure the required code and settings. For iOS projects, follow the CLI prompts to add the necessary files and configurations.

Install Clix CLI

brew tap clix-so/clix-cli
brew install clix-so/clix-cli/clix

Run Install Command

The install command in the Clix CLI checks for required files and configurations, and provides appropriate installation guidance through prompts.
clix install

Doctor Command

The clix doctor command checks whether the necessary code and configuration for using the Clix SDK are properly set up, and provides guidance on how to fix any issues.
clix doctor

Setup Clix - Manual Installation

Integrate Firebase and Clix to manage and send notifications effectively from Clix console.
GitHub release (latest by date)

1. Add Firebase SDK & Clix SDK

Option1) Using Swift Package Manager (SPM):
Option2) Using Pod:
  • Add these lines to your Podfile:
# Podfile
pod 'Firebase/Messaging'
pod 'ClixSDK'
  • Then run:
pod install

2. Add Capability and Initialization Code

To add Push Notification Capability,
  1. Select your app target.
  2. Go to the Signing & Capabilities tab.
  3. Click the + button and choose Push Notification from the list.
Add this code to AppDelegate.swift inside the didFinishLaunchingWithOptions method:
Ensure that your AppDelegate inherits from ClixAppDelegate.
import UIKit
import Clix
import FirebaseCore

class AppDelegate: ClixAppDelegate {
    override func application(_ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        FirebaseApp.configure()

        Task {
            await Clix.initialize(
                config: ClixConfig(
				    projectId: YOUR_PROJECT_ID,
                    apiKey: YOUR_PUBLIC_API_KEY
                )
            )
        }



        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

3. Build & Run

Run your project to verify the setup works correctly. Notifications should appear on your device as expected.

4. Add App Extension

  1. Create a Notification Service Extension to enhance your notification content.
  2. In Xcode, choose File > New > Target > Notification Service Extension.
  3. Name the extension ‘ClixNotificationExtension’.

5. Add App Grooup & Clix Package

  1. Select your app target.
  2. Go to the Signing & Capabilities tab.
  3. Click the + button and choose App Groups from the list.
  4. Click + under App Groups and create the App Group ID
    The App Group ID must be ‘group.clix.YOUR_PROJECT_ID’
  5. Add the same App Group Id to the Extension target.
  6. At the Extension target > ‘General’ > ‘Frameworks, Libraries …’ , click ’+’ buton and search and add ‘Cllix’ to your extension target.

6. Initialize Clix in App Extension

Add the following to your extension’s NotificationService.swift:
Note that you have to replace YOUR_PROJECT_ID to your own project id. (Check out Clix Console > Setting)
import Clix
import UserNotifications

/// NotificationService inherits all logic from ClixNotificationServiceExtension
/// No additional logic is needed unless you want to customize notification handling.
class NotificationService: ClixNotificationServiceExtension {
    // Initialize with your Clix project ID
    override init() {
        super.init()
        // Register your Clix project ID
        register(projectId: YOUR_PROJECT_ID)
    }

    override func didReceive(
        _ request: UNNotificationRequest,
        withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
    ) {
        // Call super to handle image downloading and send push received event
        super.didReceive(request, withContentHandler: contentHandler)
    }

    override func serviceExtensionTimeWillExpire() {
        super.serviceExtensionTimeWillExpire()
    }
}

7. Build & Run

Run your project to verify the setup works correctly. Go to Clix console > Test Console, find the registered device, send a push message, and check if the message is received properly on the device. Also, make sure the push events are being tracked in real time.

Post-installation Checklist

After installing and wiring the SDK, review the following critical points to avoid subtle runtime issues and ensure Clix can manage push notifications correctly.
import UIKit
import Clix
import FirebaseCore

class AppDelegate: ClixAppDelegate {
    override func application(_ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // 1. Always configure Firebase first
        FirebaseApp.configure()

        // 2. Then initialize Clix (async-safe)
        Task {
            await Clix.initialize(
                config: ClixConfig(
                    projectId: YOUR_PROJECT_ID,
                    apiKey: YOUR_PUBLIC_API_KEY
                )
            )
        }

        // 3. Return super at the very end (lets Clix finalize delegates & observers)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}
Initialize Clix after FirebaseApp.configure() Reason: Clix relies on Firebase Messaging. If Firebase isn’t configured first, FCM token retrieval and registration can fail.
Call super at the very end of each overridden lifecycle method inherited from ClixAppDelegate / ClixNotificationServiceExtension Reason: Clix’s super implementation finalizes delegate setup, event tracking, and background handling. Calling it early can overwrite or miss your custom logic; omitting it breaks internal hooks.
Remove manual assignments to Messaging.messaging().delegate and UNUserNotificationCenter.current().delegate Reason: Clix sets these delegates internally. Reassigning them can prevent delivery receipts, media attachment handling, or token sync.
If you must implement your own delegate methods (e.g., for foreground presentation), do it in your AppDelegate subclass but still avoid reassigning the delegates. Clix forwards relevant delegate callbacks so your overrides continue to work.
Need to confirm things are correct? Run clix doctor again — it re-validates configuration and highlights missing steps.

Quick Self-Test

  1. Launch the app cold start: verify no console errors about FCM or missing projectId.
  2. Send a test push: confirm receipt and event tracking in the Clix Console (real-time events panel).
  3. Foreground push: ensure notification presentation logic still works without manual delegate assignments.
If any step fails, re-check the checklist above before deeper debugging.