mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
25 lines
643 B
TypeScript
25 lines
643 B
TypeScript
|
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;
|
||
|
};
|