Documentation

Documentation

YourOwn SetupYourOwn SDKYourOwn API
Sphere SetupSphere SDKSphere API
  • Resources

›Getting started for flutter

Getting started

  • Copilot.cx Mobile SDK
  • Importing the iOS SDK
  • Importing the Android SDK
  • SDK configuration

Getting started for flutter

  • Importing the Copilot.cx Android SDK for Flutter
  • Importing the Copilot.cx iOS SDK for Flutter
  • Interacting with the Copilot.cx SDK in Dart

Getting around

  • Hello Copilot

Reference

  • Manage session
  • Report
  • In-app messages
  • Authentication

Event reporting guide

  • Predefined events
  • Custom events

Appendix

  • Releases
  • Open source mapping

Importing the Copilot.cx iOS SDK for Flutter

Setting up the iOS side for Copilot.cx SDK

  1. Please follow steps 1 through 9 in Importing the iOS SDK
  1. Add a CopilotModule class through which you'll interface with your flutter dart code using the FlutterMethodChannel. Inside the setupMethodChannel function, we'll "capture" function calls from the dart side(with or without parameters) and point them to our native side fuctions. In this following example we're using the startSession, endSession and sendEvent functions.
import Flutter
import CopilotAPIAccess // use CopilotCX if pulled from SPM

class CopilotModule {
    private let channel = "myProjectChannelName"
    
    init(_ controller: FlutterViewController) {
        setupMethodChannel(with: controller)
    }
    
    fileprivate func setupMethodChannel(with controller: FlutterViewController) {
        let methodChannel = FlutterMethodChannel(name: channel, binaryMessenger: controller.binaryMessenger)
        
        methodChannel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) in
            switch (call.method) {
            case "startSession":
                if let args = call.arguments as? [String: Any] {
                    let userId = args["userId"] as? String
                    self.startSession(userId: userId)
                }
            case "endSession":
                self.endSession()
            default:
                    print("Unhandled")
            }
        }
    }
    
    func startSession(userId: String?) {
        if let userId = userId {
            Copilot.instance.manage.yourOwn.sessionStarted(withUserId: userId, isCopilotAnalysisConsentApproved: true)
        }
    }
    
    func endSession() {
        Copilot.instance.manage.yourOwn.sessionEnded()
    }
}
  1. Initialize the CopilotModule in your AppDelegate through which all Copilot functions will be activated and then initialize Copilot.cx, setting it with a list of EventLogProviders as shown below (please refer the Managing providers section).
import CopilotAPIAccess // use CopilotCX if pulled from SPM

override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    ...
    let controller = window?.rootViewController as! FlutterViewController
    let copilotModule = CopilotModule(controller)
    Copilot.setup(analyticsProviders: [FirebaseAnalyticsProvider()])
    ...
}
← Importing the Copilot.cx Android SDK for FlutterInteracting with the Copilot.cx SDK in Dart →
  • Setting up the iOS side for Copilot.cx SDK
Copilot
Mail: hello@copilot.cx
Call: (212).398.0001
© Copilot.cx 2025