import { Platform } from 'react-native';
import MyAppList from './NativeMyAppList';

export interface InstalledApp {
  packageName: string;
  appName: string;
  versionName: string;
  versionCode: number;
  isSystemApp: boolean;
}

export const getInstalledApps = async (): Promise<InstalledApp[]> => {
  if (Platform.OS !== 'android') {
    throw new Error('This feature is only available on Android');
  }
  
  try {
    return await MyAppList.getInstalledApps();
  } catch (error) {
    throw new Error(`Failed to get installed apps: ${error}`);
  }
};
