SDK Reference

Class CredoAppService

iOS Android

The primary interface for interacting with the Credolab Capacitor SDK. This class serves as a bridge between your Capacitor application and the native SDK implementations on iOS and Android.

import { CredoAppService } from '@credolab/capacitor-core';

const service = new CredoAppService();

Methods

setForceResolvePermissions

iOS

Configures the automatic permission request behavior on iOS. When enabled, the SDK automatically prompts the user for required permissions during data collection.

Signature

service.setForceResolvePermissions(value: boolean): void

Parameters

NameTypeDefaultDescription
valuebooleantrueWhen true, the SDK automatically requests permissions. When false, the SDK skips permission requests (assumes permissions are handled by the host application).

Example

// Disable automatic permission requests (handle permissions manually)
service.setForceResolvePermissions(false);
📘

IosMusicModule Exception

The Music permission (NSAppleMusicUsageDescription) is always requested automatically by the SDK when using IosMusicModule, regardless of this setting.


setIgnorePermissions

Android

Controls whether the SDK should proceed with data collection when permissions are not fully granted on Android.

Signature

service.setIgnorePermissions(value: boolean): void

Parameters

NameTypeDefaultDescription
valuebooleantrueWhen true, data collection proceeds even if some permissions are not granted (partial data collection). When false, data collection is blocked until all required permissions are granted.

Example

// Require all permissions before data collection
service.setIgnorePermissions(false);

Behavior Summary

ValueBehavior
trueCollects available data even with missing permissions
falseBlocks collectAsync() until all permissions (including normal permissions) are granted

addModuleAsync

iOS Android

Registers a data collection module with the CredoAppService instance. Modules are platform-specific and should be added based on the target platform.

Signature

service.addModuleAsync(module: Module): Promise<void>

Parameters

NameTypeDescription
moduleModuleA platform-specific module instance (see supported modules below)

Returns

TypeDescription
Promise<void>Resolves when the module is successfully registered

Supported Modules

Android Modules

ModuleDescription
AndroidAccountModuleCollects device account information
AndroidAudioModuleCollects audio metadata
AndroidCalendarModuleCollects calendar events data
AndroidCallLogModuleCollects call history metadata
AndroidContactModuleCollects contacts metadata
AndroidGuardModuleCollects device security information
AndroidImagesModuleCollects image metadata
AndroidIovationModuleIntegrates TruValidate (Iovation) fraud detection
AndroidSmsModuleCollects SMS metadata
AndroidTelephonyModuleCollects telephony information
AndroidVideoModuleCollects video metadata

iOS Modules

ModuleDescription
IosApplicationModuleCollects application information
IosCalendarEventsModuleCollects calendar events data
IosCalendarRemindersModuleCollects calendar reminders data
IosContactModuleCollects contacts metadata
IosIovationModuleIntegrates TruValidate (Iovation) fraud detection
IosLocationModuleCollects location data
IosMediaModuleCollects media library metadata
IosMusicModuleCollects music library metadata
IosTelephonyModuleCollects telephony information

Example

import { CredoAppService } from '@credolab/capacitor-core';
import { AndroidContactModule } from '@credolab/capacitor-android-contact';
import { IosContactModule } from '@credolab/capacitor-ios-contact';

const service = new CredoAppService();

// Add platform-specific modules
await service.addModuleAsync(new AndroidContactModule());
await service.addModuleAsync(new IosContactModule());

collectAsync

iOS Android

Initiates the data collection process across all registered modules and returns the encrypted dataset.

Signature

service.collectAsync(): Promise<string>

Returns

TypeDescription
Promise<string>Resolves with a compressed, encrypted JSON dataset string

Example

try {
  const dataset = await service.collectAsync();
  console.log('Dataset collected successfully');
  // Send dataset to your server for upload to Credolab
} catch (error: unknown) {
  const message = error instanceof Error ? error.message : String(error);
  const code = error instanceof Error && 'code' in error ? (error as any).code : 'UNKNOWN';
  // Log error details to telemetry service for analysis (console used for testing)
  console.error(`Failed to collect dataset [${code}]: ${message}`);
    
  throw error; // Re-throw to let caller handle it
}

Error Codes

CodeNameDescription
30Duplicated AreasThe specified extraction areas are duplicated. Ensure each module is added only once.
90Unknown ErrorAn unexpected error occurred during data collection.

See Also