1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/hooks/useIsAppleDevice.ts

25 lines
644 B
TypeScript
Raw Normal View History

import { useEffect, useState } from 'react';
export const useIsAppleDevice = () => {
const [isAppleDevice, setIsAppleDevice] = useState<boolean>();
useEffect(() => {
const platform =
(
navigator as unknown as {
userAgentData: { platform: string };
}
)?.userAgentData?.platform ||
navigator?.platform ||
'unknown';
setIsAppleDevice(
platform.toLowerCase().includes('mac') ||
platform === 'iPhone' ||
platform === 'iPad',
);
}, []);
return isAppleDevice;
};