Device Adapters
Collect device, OS, and app information with platform adapters.
Device adapters collect device and application information for identification and analytics. You must provide a device adapter when initializing TeardownCore.
Available Adapters
| Adapter | Package | Best For |
|---|---|---|
ExpoDeviceAdapter | expo-device, expo-application | Expo projects |
DeviceInfoAdapter | react-native-device-info | Bare RN projects |
BasicAdapter | None | Fallback/testing |
Collected Information
All device adapters provide:
Application Info
interface ApplicationInfo {
version: string; // App version (e.g., "1.2.3")
build_number: number; // Build number (e.g., 45)
}Hardware Info
interface HardwareInfo {
device_name: string; // Device name (e.g., "iPhone 14 Pro")
device_brand: string; // Manufacturer (e.g., "Apple")
device_type: string; // Device type (e.g., "phone", "tablet")
}OS Info
interface OSInfo {
platform: DevicePlatformEnum; // Platform enum (IOS, ANDROID, etc.)
name: string; // OS name (e.g., "iOS", "Android")
version: string; // OS version (e.g., "17.0")
}DevicePlatformEnum
enum DevicePlatformEnum {
IOS = "IOS",
ANDROID = "ANDROID",
WEB = "WEB",
WINDOWS = "WINDOWS",
MACOS = "MACOS",
LINUX = "LINUX",
UNKNOWN = "UNKNOWN",
}Usage
import { TeardownCore } from '@teardown/force-updates';
import { ExpoDeviceAdapter } from '@teardown/force-updates/adapters/expo';
import { MMKVStorageAdapter } from '@teardown/force-updates/adapters/mmkv';
const teardown = new TeardownCore({
org_id: 'your-org-id',
project_id: 'your-project-id',
api_key: 'your-api-key',
storageAdapter: new MMKVStorageAdapter(),
deviceAdapter: new ExpoDeviceAdapter(),
});Device ID
The SDK generates a stable device ID that persists across app sessions:
const deviceId = await core.device.getDeviceId();
// Returns a UUID that persists in storageTo reset the device ID (device will appear as new install):
core.device.reset();
// Next getDeviceId() call will generate a new IDCustom Adapter
Extend the DeviceInfoAdapter abstract class:
import {
DeviceInfoAdapter,
DevicePlatformEnum,
type ApplicationInfo,
type HardwareInfo,
type OSInfo,
} from '@teardown/force-updates';
class CustomDeviceAdapter extends DeviceInfoAdapter {
get applicationInfo(): ApplicationInfo {
return {
version: '1.0.0',
build_number: 1,
};
}
get hardwareInfo(): HardwareInfo {
return {
device_name: 'Custom Device',
device_brand: 'Custom',
device_type: 'phone',
};
}
get osInfo(): OSInfo {
return {
platform: DevicePlatformEnum.IOS,
name: 'iOS',
version: '17.0',
};
}
}