Files
zellyy-finance/src/utils/platform.ts
gpt-engineer-app[bot] 51bcdf2d05 Center align app version info
Center align the app version and description text in the settings page.
2025-03-21 13:17:30 +00:00

68 lines
1.7 KiB
TypeScript

/**
* 플랫폼 관련 유틸리티 함수들
*/
import { Capacitor } from '@capacitor/core';
/**
* 안드로이드 플랫폼인지 확인
*/
export const isAndroidPlatform = (): boolean => {
return Capacitor.getPlatform() === 'android';
};
/**
* iOS 플랫폼인지 확인
*/
export const isIOSPlatform = (): boolean => {
return Capacitor.getPlatform() === 'ios';
};
/**
* 웹 플랫폼인지 확인
*/
export const isWebPlatform = (): boolean => {
return Capacitor.getPlatform() === 'web';
};
/**
* 네이티브 플랫폼(Android 또는 iOS)인지 확인
*/
export const isNativePlatform = (): boolean => {
return isAndroidPlatform() || isIOSPlatform();
};
/**
* 앱 버전 정보 가져오기
*/
export const getAppVersionInfo = async () => {
try {
// BuildInfoPlugin이 설치되어 있다면 사용
if (Capacitor.isPluginAvailable('BuildInfo')) {
// Capacitor.Plugins 대신에 직접 window 객체에서 접근
// @ts-ignore - 플러그인이 런타임에 등록되므로 타입 체크를 무시
const buildInfo = await Capacitor.Plugins?.BuildInfo?.getBuildInfo();
return {
versionName: buildInfo?.versionName || '1.0.1',
buildNumber: buildInfo?.buildNumber ? parseInt(buildInfo.buildNumber, 10) : 2,
versionCode: buildInfo?.versionCode
? parseInt(buildInfo.versionCode, 10)
: undefined
};
}
// 플러그인이 없으면 기본값 반환
return {
versionName: '1.0.1',
buildNumber: 2
};
} catch (error) {
console.error('앱 버전 정보를 가져오는 중 오류 발생:', error);
return {
versionName: '1.0.1',
buildNumber: 2
};
}
};