Initialise SDK

This section provides information on initialisation of the SDK.

To initiate the Capillary SDK,

  1. Create an instance of the SDK for each application. This API needs to be called in the onCreate() of the application class with the HydraConfig. You can use this instance in your code to interact with the SDK.

  2. fun instanceWithConfig(  
       context: Context, config: HydraConfig  
    ): HydraAPI
    
    public HydraAPI instanceWithConfig(Context context, HydraConfig config) {
        // Function body goes here
    }
    
  3. Provide configuration in the SDK usingHydraConfig. The SDK accepts several parameters. The parameter accountId is mandatory. If accountID is not provided, the SDK throws an exception. All other parameters are optional.

    var accountId: String,  
    var baseURL: String?,  
    var sslPublicKey: String?,  
    var country: String?,  
    var city: String?,  
    var countryCode: String?,  
    var captureViewPortDetails: Boolean,  
    var isDisableAppLaunchedEvent: Boolean,  
    var debugLevel: Int  
    var fcmConfig:FcmConfig = defaultFcmConfig(),  
    val notificationConfig: NotificationConfig? = null
    
    String accountId;
    String baseURL;
    String sslPublicKey;
    String country;
    String city;
    String countryCode;
    boolean captureViewPortDetails;
    boolean isDisableAppLaunchedEvent;
    int debugLevel;
    FcmConfig fcmConfig = defaultFcmConfig();
    
  4. Add the SDK initialization block in the onCreate callback of your application class as shown below:

    val hydraConfig = HydraConfig.Builder(  
       applicationContext,  
       accountId = "PARTNER_ACCOUNT_ID"  
    )  
       .debugLevel(LogType.VERBOSE)  
       .captureViewPortDetails(true)  
       .country("India")  
       .city("Pune")  
       .countryCode("91")  
       .baseURL("PARTNER_HYDRA_URL")  
       .sslPublicKey("PARTNER_SSL_PUBLIC_KEY_FOR_HYDRA_URL")  
       .build()
    
    HydraConfig hydraConfig = new HydraConfig.Builder(applicationContext)
        .setAccountId("PARTNER_ACCOUNT_ID")
        .setDebugLevel(LogType.VERBOSE)
        .setCaptureViewPortDetails(true)
        .setCountry("India")
        .setCity("Pune")
        .setCountryCode("91")
        .setBaseURL("PARTNER_HYDRA_URL")
        .setSslPublicKey("PARTNER_SSL_PUBLIC_KEY_FOR_HYDRA_URL")
        .build();
    
    ParameterTypeDescriptionMandatory/Optional
    accountIdStringAccount ID of the partnerMandatory
    .debugLevelLogTypeLogging Config i.e. OFF(-1), INFO(0), DEBUG(1), VERBOSE(2)Optional
    .captureViewPortDetailsBooleanCapture ViewPort informationOptional
    .countryStringCountry nameOptional
    .cityStringCity nameOptional
    .countryCodeStringCountry code valueOptional
    .baseURLStringBase URL of regionOptional
    .sslPublicKeyStringValid SSL Public Key of URLOptional
    .fcmConfigFcmConfig objectFirebase ConfigurationOptional (If not using Firebase SDK)
    .notificationConfigNotificationConfig objectNotification ConfigurationOptional (If not using Firebase SDK)
  5. Create an instance of the HydraAPI with HydraConfig. Use the below functional call:
    HydraAPI.instanceWithConfig(applicationContext, hydraConfig)

    ParameterTypeDescriptionOptional/Mandatory
    applicationContextContextApplication contextMandatory
    hydraConfigHydraConfigHydraConfig objectMandatory