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

인앱 브라우저 등장 조건, 문구 변경 #438

Merged
merged 3 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 15 additions & 3 deletions src/presentation/components/InAppBrowserEscape/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import CommonModal from '@components/common/Modal';
import React, { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';

import { useLoginUser } from '@hooks/useLoginUser';

const InAppBrowserEscape = () => {
const [isModalOpened, setIsModalOpened] = useState(false);
const { isAuthenticated } = useLoginUser();

const openRealBrowser = useCallback(() => {
const isIOS = navigator.userAgent.match(/iPhone|iPad/i);
if (isIOS) {
Expand All @@ -14,21 +18,29 @@ const InAppBrowserEscape = () => {
'#Intent;scheme=http;package=com.android.chrome;end';
}
}, []);

useEffect(() => {
if (!isAuthenticated) return;

const isInAppBrowser = navigator.userAgent.match(
/inapp|NAVER|KAKAOTALK|Snapchat|Line|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 (isInAppBrowser !== null) setIsModalOpened(true);
}, []);
}, [isAuthenticated]);

return (
<CommonModal
title="알림"
description={
'더 쾌적하게 너가소개서를 이용하기 위해' + '\n' + '외부 브라우저에서 접속해 주세요.'
'크롬 앱으로 접속하면' +
'\n' +
'더 쾌적한 환경에서 이용할 수 있습니다.' +
'\n' +
'*크롬 앱이 없다면 취소를 눌러주세요'
}
onClickCancel={() => setIsModalOpened(false)}
onClickConfirm={openRealBrowser}
confirmLabel="크롬에서 보기"
isOpened={isModalOpened}
/>
);
Expand Down
5 changes: 3 additions & 2 deletions src/presentation/components/common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ interface CommonModalProps {
title: string;
description?: string;
isOpened: boolean;
confirmLabel?: string;
}

export default function CommonModal(props: CommonModalProps) {
const { onClickConfirm, onClickCancel, title, description, isOpened } = props;
const { onClickConfirm, onClickCancel, title, description, isOpened, confirmLabel } = props;
return (
<ModalWrapper isOpened={isOpened}>
<StCommonModal>
Expand All @@ -20,7 +21,7 @@ export default function CommonModal(props: CommonModalProps) {
{description && <StDescription>{description}</StDescription>}
<div>
<button onClick={onClickCancel}>취소</button>
<button onClick={onClickConfirm}>확인</button>
<button onClick={onClickConfirm}>{confirmLabel ?? '확인'}</button>
</div>
</StCommonModal>
</ModalWrapper>
Expand Down