Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 모바일 크롬 접속 시 크롬으로 접속 권하는 alert 뜨는 에러 해결 #470

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/common/hooks/useCheckBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { useEffect } from 'react';

const useCheckBrowser = () => {
useEffect(() => {
const isChrome = /Chrome/i.test(window.navigator.userAgent);
const userAgent = window.navigator.userAgent;

const chromeRegexes = [
/\b(?:crmo|crios)\/([\w\.]+)/i, // Chrome for Android/iOS
/headlesschrome(?:\/([\w\.]+)| )/i, // Chrome Headless
/ wv\).+(chrome)\/([\w\.]+)/i, // Chrome WebView
/chrome\/([\w\.]+) mobile/i, // Chrome Mobile
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i, // ChromeOS (Chromium OS)
];

const isChrome = chromeRegexes.some((regex) => regex.test(userAgent));

if (!isChrome) {
alert('원활한 지원을 위해 크롬(Chrome) 브라우저 사용을 권장드려요.');
}
Expand Down