Initialise SDK

This section provides information on initialisation of the iOS SDK.


A sample application Hydra Sample App is available for testing framework integration and APIs.

To initialise the Capillary iOS SDK, perform the following:

  1. Open the AppDelegate file in your Xcode project.

  2. Locate the method application(_:didFinishLaunchingWithOptions:). If not available, use the below code and create the method.

    optional func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
    ) -> Bool
  3. Add the below code to the method and create the HydraCore instance. You need to create an instance of the SDK for each application separately.

    static public func generate(with configuration: ConfigurationGenerator,
                                    geoData: GeographicDataGenerator? = nil,
                                    supportsPushNotifications: Bool = false,
                                    deviceScreenInfo: DeviceScreenInfo? = nil) throws -> Hydra

    The table below provides an overview of the parameters, their corresponding types, descriptions, and whether they are mandatory or optional.

    HydraConfigurationConfigurationGeneratorAn object of class conforming to ConfigurationGenerator protocolMandatory
    GeoDataGeographicDataGeneratorUser's geographic detailsOptional
    supportsPushNotificationsBoolDevice's push notification settingsMandatory
    DeviceScreenInfoDeviceScreenInfoDevice screen sizeOptional
  4. Retrieve the parameter values for the required configuration (HydraConfiguration, GeoData, and DeviceScreenInfo). Use the below code snippets:

    1. HydraConfiguration (Mandatory)

      public protocol ConfigurationGenerator {
          var accountID: String {get set}
          var customerId: String {get set}
          var server: ServerConfig {get set}
      accountIDStringAccount ID of partnerMandatory
      customerIdStringPhone/email/external IDMandatory
      serverServerConfigServer configurationOptional
    2. GeoData(Optional)

      This is optional and needs to be passed only if the below values have to be sent to the SDK.

      public protocol GeographicDataGenerator {
          var country: String? {get set}
          var city: String? {get set}
          var countryCode: String? {get set}
          var timeZone: String {get set}
    3. DeviceScreenInfo(Optional)

      This is optional and needs to be passed only if the below values have to be sent to the SDK.

      public protocol DeviceScreenInfoGenerator {
          var screenWidth: Int {get set}
          var screenHeight: Int {get set}
      screenWidthIntDevice screen widthMandatory
      screenHeightIntDevice screen heightMandatory
  5. Initialise the SDK. See the below example:

      do {
                let config = HydraConfiguration(accountID: "account-id", customerId: "customer-id", server: .server1)
                let geoData = GeoData(country: "country", countryCode: "country-code", city: "city", timeZone: "timezone")
                let deviceInfo = DeviceScreenInfo(screenHeight: 00, screenWidth: 00)
                let supportsPushNotifications = true
                Hydra.generate(with: config,
                               geoData: geoData,
                               supportsPushNotifications: supportsPushNotifications,
                               deviceScreenInfo: deviceInfo)
            } catch let error {
                print("Failed to initialise Hydra SDK")
  6. Placeholder

The SDK also allows to set of additional parameters at a later stage, after the SDK has been initialized. You can set the following parameters:

  • Customer Id
  • Device Token
  • InterfaceId/FCM Token
  • Notification support ie Users notification settings status

Updating customer Id

To set a customer Id or to update a customer ID, use the below API. Whenever the customer Id changes in the app, the same must be updated in the SDK.

public func update(customerID id:String)


hydraCore.update(customerID: "customer-id")

Updating device token

You need to update the device's push token to ensure continued receipt of push notifications. use the below API:

public func update(deviceToken id: String)


hydraCore.update(deviceToken: "device-token")

If you are using Firebase for receiving push notifications, use the below API:

public func update((interfaceID id: String)

Updating interfaceId/FCM token

For the application to receive remote notifications properly, you must update the Firebase Cloud Messaging (FCM) token whenever necessary. Use the below API:

public func update(interfaceID id: String) 


hydraCore.update(interfaceID: "FCM-Token")

Updating notification support

You can enable or disable the support for notifications in your application. Use the below API:

public func update(notificationSupport status: Bool


hydraCore.update(notificationSupport: true)

Updating log level

Capillary SDK has a logging mechanism that enables the application to view all the SDK logs. The SDK logs statements at various levels and allows the application to determine the extent of logs it wishes to observe. The application can print records as per its requirements, enabling efficient monitoring and debugging capabilities.

criticalCritical messages indicate a serious problem and may result in the failure of the application
errorError messages indicate a problem that has occurred, but the application may continue to run.
infoInfo messages provide general information about the application's operation.
debugDebug messages provide detailed information about the application's operation, which can be useful for debugging problems.
verboseVerbose messages provide extremely detailed information about the application's operation, which can be useful for troubleshooting problems.


public func updateLogLevel(level: LogLevel)


By default, the updateLogLevel is set as verbose.


hydraCore.updateLogLevel(level: .critical)