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
Configures the automatic permission request behavior on iOS. When enabled, the SDK automatically prompts the user for required permissions during data collection.
When true, the SDK automatically requests permissions. When false, the SDK skips permission requests (assumes permissions are handled by the host application).
The Music permission (NSAppleMusicUsageDescription) is always requested automatically by the SDK when using IosMusicModule, regardless of this setting.
setIgnorePermissions
Controls whether the SDK should proceed with data collection when permissions are not fully granted on Android.
When 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
Value
Behavior
true
Collects available data even with missing permissions
false
Blocks collectAsync() until all permissions (including normal permissions) are granted
addModuleAsync
Registers a data collection module with the CredoAppService instance. Modules are platform-specific and should be added based on the target platform.
A platform-specific module instance (see supported modules below)
Returns
Type
Description
Promise<void>
Resolves when the module is successfully registered
Supported Modules
Android Modules
Module
Description
AndroidAccountModule
Collects device account information
AndroidAudioModule
Collects audio metadata
AndroidCalendarModule
Collects calendar events data
AndroidCallLogModule
Collects call history metadata
AndroidContactModule
Collects contacts metadata
AndroidGuardModule
Collects device security information
AndroidImagesModule
Collects image metadata
AndroidIovationModule
Integrates TruValidate (Iovation) fraud detection
AndroidSmsModule
Collects SMS metadata
AndroidTelephonyModule
Collects telephony information
AndroidVideoModule
Collects video metadata
iOS Modules
Module
Description
IosApplicationModule
Collects application information
IosCalendarEventsModule
Collects calendar events data
IosCalendarRemindersModule
Collects calendar reminders data
IosContactModule
Collects contacts metadata
IosIovationModule
Integrates TruValidate (Iovation) fraud detection
IosLocationModule
Collects location data
IosMediaModule
Collects media library metadata
IosMusicModule
Collects music library metadata
IosTelephonyModule
Collects 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
Initiates the data collection process across all registered modules and returns the encrypted dataset.
Signature
service.collectAsync(): Promise<string>
Returns
Type
Description
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
Code
Name
Description
30
Duplicated Areas
The specified extraction areas are duplicated. Ensure each module is added only once.
90
Unknown Error
An unexpected error occurred during data collection.