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(  
       accountId = "PARTNER_ACCOUNT_ID"  
    HydraConfig hydraConfig = new HydraConfig.Builder(applicationContext)
    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)

    applicationContextContextApplication contextMandatory
    hydraConfigHydraConfigHydraConfig objectMandatory