From 880b1bb2a2cc2b83458d22579710bd62d53b2ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=8C=EC=9A=B8=EC=B9=98=ED=82=A8?= <90738604+soulchicken@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:57:53 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=9D=B8=EC=95=B1=20=EB=B8=8C=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=EC=A0=80=EC=97=90=EC=84=9C=20=EC=98=AE=EA=B2=A8?= =?UTF-8?q?=EA=B0=80=EB=8A=94=20=EB=B2=84=ED=8A=BC=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/inApp/InApp.tsx | 39 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/components/common/inApp/InApp.tsx b/src/components/common/inApp/InApp.tsx index 9cbcf0e..96d7783 100644 --- a/src/components/common/inApp/InApp.tsx +++ b/src/components/common/inApp/InApp.tsx @@ -1,10 +1,45 @@ +/* eslint-disable no-restricted-globals */ import { Theme, themeTable } from '@/styles/color'; import { css } from '@emotion/react'; const InApp = () => { const handleButtonClick = () => { - if (typeof window !== 'undefined') { - window.open(window.location.href, '_blank'); + const userAgent = navigator.userAgent.toLowerCase(); + const targetUrl = location.href; + if (userAgent.match(/kakaotalk/i)) { + // 카카오톡 외부브라우저로 호출 + location.href = `kakaotalk://web/openExternal?url=${encodeURIComponent(targetUrl)}`; + } else if (userAgent.match(/line/i)) { + // 라인 외부브라우저로 호출 + if (targetUrl.indexOf('?') !== -1) { + location.href = `${targetUrl}&openExternalBrowser=1`; + } else { + location.href = `${targetUrl}?openExternalBrowser=1`; + } + } else if ( + userAgent.match( + /inapp|naver|snapchat|wirtschaftswoche|thunderbird|instagram|everytimeapp|whatsApp|electron|wadiz|aliapp|zumapp|iphone(.*)whale|android(.*)whale|kakaostory|band|twitter|DaumApps|DaumDevice\/mobile|FB_IAB|FB4A|FBAN|FBIOS|FBSS|SamsungBrowser\/[^1]/i, + ) + ) { + // 그외 다른 인앱들 + if (userAgent.match(/iphone|ipad|ipod/i)) { + // 아이폰은 강제로 사파리를 실행할 수 없다. + // 모바일 대응 뷰포트 강제설정 + const mobile = document.createElement('meta'); + mobile.name = 'viewport'; + mobile.content = 'width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, minimal-ui'; + document.getElementsByTagName('head')[0].appendChild(mobile); + // 노토 산스 폰트 강제 설정 + const fonts = document.createElement('link'); + fonts.href = 'https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap'; + document.getElementsByTagName('head')[0].appendChild(fonts); + document.body.innerHTML = "