CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-native-device-info

Get device information using react-native

Pending
Overview
Eval results
Files

application-information.mddocs/

Application Information

Application metadata including version information, installation details, and app-specific identifiers. Useful for app analytics, version checking, and installation tracking.

Capabilities

Basic Application Information

Get basic application metadata and identifiers.

/**
 * Get application name
 * @returns Application name string
 * @platforms Android, iOS, Windows
 */
function getApplicationName(): string;

/**
 * Get bundle identifier
 * @returns Bundle ID string (e.g., "com.example.app")
 * @platforms Android, iOS, Windows
 */
function getBundleId(): string;

/**
 * Get application version
 * @returns Version string (e.g., "1.2.3")
 * @platforms Android, iOS, Windows
 */
function getVersion(): string;

/**
 * Get build number
 * @returns Build number string
 * @platforms Android, iOS, Windows
 */
function getBuildNumber(): string;

/**
 * Get readable version (version + build number)
 * @returns Combined version and build number
 * @platforms Android, iOS, Windows
 */
function getReadableVersion(): string;

Usage Examples:

import { 
  getApplicationName, 
  getBundleId, 
  getVersion, 
  getBuildNumber,
  getReadableVersion 
} from 'react-native-device-info';

// Basic app information
const appName = getApplicationName();
const bundleId = getBundleId();
const version = getVersion();
const buildNumber = getBuildNumber();
const readableVersion = getReadableVersion();

console.log(`App: ${appName} (${bundleId})`);
console.log(`Version: ${version}`);
console.log(`Build: ${buildNumber}`);
console.log(`Full Version: ${readableVersion}`);

// Version checking for updates
const currentVersion = version;
const minimumSupportedVersion = '1.0.0';
const needsUpdate = compareVersions(currentVersion, minimumSupportedVersion) < 0;

Installation Information

Get information about app installation and updates.

/**
 * Get first install time (async)
 * @returns Promise resolving to timestamp of first install
 * @platforms Android, iOS, Windows
 */
function getFirstInstallTime(): Promise<number>;

/**
 * Get first install time (sync)
 * @returns Timestamp of first install
 * @platforms Android, iOS, Windows
 */
function getFirstInstallTimeSync(): number;

/**
 * Get last update time (async)
 * @returns Promise resolving to timestamp of last update
 * @platforms Android
 */
function getLastUpdateTime(): Promise<number>;

/**
 * Get last update time (sync)
 * @returns Timestamp of last update
 * @platforms Android
 */
function getLastUpdateTimeSync(): number;

/**
 * Get installer package name (async)
 * @returns Promise resolving to installer package name
 * @platforms Android, Windows, iOS
 */
function getInstallerPackageName(): Promise<string>;

/**
 * Get installer package name (sync)
 * @returns Installer package name string
 * @platforms Android, Windows, iOS
 */
function getInstallerPackageNameSync(): string;

Usage Examples:

import { 
  getFirstInstallTime, 
  getLastUpdateTime, 
  getInstallerPackageName 
} from 'react-native-device-info';

// Installation timing
const firstInstall = new Date(await getFirstInstallTime());
console.log(`First installed: ${firstInstall.toLocaleDateString()}`);

if (Platform.OS === 'android') {
  const lastUpdate = new Date(await getLastUpdateTime());
  console.log(`Last updated: ${lastUpdate.toLocaleDateString()}`);
  
  // Check how long since last update
  const daysSinceUpdate = (Date.now() - await getLastUpdateTime()) / (1000 * 60 * 60 * 24);
  console.log(`Days since update: ${Math.floor(daysSinceUpdate)}`);
}

// Installation source
const installer = await getInstallerPackageName();
console.log(`Installed from: ${installer}`);

// Determine install source
const isPlayStoreInstall = installer === 'com.android.vending';
const isSideloaded = installer === 'unknown';
console.log(`Play Store install: ${isPlayStoreInstall}`);
console.log(`Sideloaded: ${isSideloaded}`);

Installation and Referrer Tracking

Get installation referrer and marketing attribution information.

/**
 * Get install referrer (async)
 * @returns Promise resolving to install referrer string
 * @platforms Android, Windows, Web
 */
function getInstallReferrer(): Promise<string>;

/**
 * Get install referrer (sync)
 * @returns Install referrer string
 * @platforms Android, Windows, Web
 */
function getInstallReferrerSync(): string;

Usage Examples:

import { getInstallReferrer } from 'react-native-device-info';

// Marketing attribution
const referrer = await getInstallReferrer();
console.log(`Install referrer: ${referrer}`);

// Parse referrer for campaign tracking
if (referrer && referrer !== 'unknown') {
  const params = new URLSearchParams(referrer);
  const utmSource = params.get('utm_source');
  const utmCampaign = params.get('utm_campaign');
  
  console.log(`Traffic source: ${utmSource}`);
  console.log(`Campaign: ${utmCampaign}`);
}

App Performance Metrics

Get app startup and performance timing information.

/**
 * Get app startup time (async)
 * @returns Promise resolving to startup time in milliseconds
 * @platforms Android, iOS
 */
function getStartupTime(): Promise<number>;

/**
 * Get app startup time (sync)
 * @returns Startup time in milliseconds
 * @platforms Android, iOS
 */
function getStartupTimeSync(): number;

Usage Examples:

import { getStartupTime } from 'react-native-device-info';

// Performance monitoring
const startupTime = await getStartupTime();
console.log(`App startup time: ${startupTime}ms`);

// Performance analytics
if (startupTime > 5000) {
  console.warn('Slow startup detected');
  // Send analytics event for slow startup
}

// Compare with previous launches
const averageStartupTime = 3000; // from analytics
const isSlowerThanAverage = startupTime > averageStartupTime * 1.5;
if (isSlowerThanAverage) {
  console.log('Startup slower than average');
}

User Agent Information

Get user agent string for web compatibility and analytics.

/**
 * Get user agent string (async)
 * @returns Promise resolving to user agent string
 * @platforms Android, iOS, Web
 */
function getUserAgent(): Promise<string>;

/**
 * Get user agent string (sync)
 * @returns User agent string
 * @platforms Android, Web
 */
function getUserAgentSync(): string;

Usage Examples:

import { getUserAgent, getUserAgentSync } from 'react-native-device-info';

// Web compatibility
const userAgent = await getUserAgent();
console.log(`User Agent: ${userAgent}`);

// Parse user agent for browser detection (Web platform)
if (Platform.OS === 'web') {
  const userAgentSync = getUserAgentSync();
  const isChrome = userAgentSync.includes('Chrome');
  const isSafari = userAgentSync.includes('Safari') && !isChrome;
  const isFirefox = userAgentSync.includes('Firefox');
  
  console.log(`Browser: ${isChrome ? 'Chrome' : isSafari ? 'Safari' : isFirefox ? 'Firefox' : 'Other'}`);
}

// Analytics tracking
const analyticsData = {
  userAgent,
  timestamp: Date.now(),
  platform: Platform.OS
};

Display and UI Information

Get display scaling and font information.

/**
 * Get font scale factor (async)
 * @returns Promise resolving to font scale factor
 * @platforms Android, iOS, Windows
 */
function getFontScale(): Promise<number>;

/**
 * Get font scale factor (sync)
 * @returns Font scale factor number
 * @platforms Android, iOS, Windows
 */
function getFontScaleSync(): number;

/**
 * Check if screen is in landscape mode (async)
 * @returns Promise resolving to true if landscape
 * @platforms All (uses Dimensions API)
 */
function isLandscape(): Promise<boolean>;

/**
 * Check if screen is in landscape mode (sync)
 * @returns True if screen is in landscape mode
 * @platforms All (uses Dimensions API)
 */
function isLandscapeSync(): boolean;

Usage Examples:

import { getFontScale, isLandscape } from 'react-native-device-info';

// Accessibility and UI scaling
const fontScale = await getFontScale();
console.log(`Font scale: ${fontScale}`);

// Adjust UI for accessibility
const isLargeText = fontScale > 1.3;
if (isLargeText) {
  console.log('Large text accessibility setting detected');
}

// Orientation detection
const landscape = await isLandscape();
console.log(`Landscape mode: ${landscape}`);

// Responsive design
const orientation = landscape ? 'landscape' : 'portrait';
console.log(`Current orientation: ${orientation}`);

Install with Tessl CLI

npx tessl i tessl/npm-react-native-device-info

docs

application-information.md

battery-power.md

device-identification.md

hardware-features.md

index.md

memory-storage.md

network-connectivity.md

react-hooks.md

system-information.md

tile.json