33 lines
946 B
TypeScript
33 lines
946 B
TypeScript
import { useCore } from "@/app/hooks/useCore";
|
|
import { useEffect, useState } from "react";
|
|
|
|
export function useCoreDevice() : {
|
|
deviceId: string;
|
|
deviceName: string;
|
|
platform: string;
|
|
} {
|
|
const { getDeviceId, getDeviceName, getPlatform } = useCore();
|
|
const [deviceId, setDeviceId] = useState<string>("");
|
|
const [deviceName, setDeviceName] = useState<string>("");
|
|
const [platform, setPlatform] = useState<string>("");
|
|
|
|
useEffect(() => {
|
|
fetchDeviceInfo();
|
|
}, []);
|
|
|
|
const fetchDeviceInfo = async () => {
|
|
const deviceId = await getDeviceId();
|
|
const deviceName = await getDeviceName();
|
|
const platform = await getPlatform();
|
|
setDeviceId(deviceId);
|
|
setDeviceName(deviceName);
|
|
setPlatform(platform);
|
|
console.info("Device info - ID:", deviceId, "Name:", deviceName);
|
|
}
|
|
|
|
return {
|
|
deviceId,
|
|
deviceName,
|
|
platform
|
|
}
|
|
} |