Skip to content

Commit

Permalink
feat: add deeplink router
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Dec 12, 2023
1 parent 02a4ed8 commit 3828bb8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/o/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use client"
import {useEffect, useState} from "react";

export default function Page() {
const appStoreUrl = 'https://itunes.apple.com/kr/app/id393499958';
const [isIphone, setIsIphone] = useState(false);
useEffect(() => {
const isIphone = () => {
const unknownWindow = ((window as unknown) as any);
const userAgent = navigator.userAgent || navigator.vendor || unknownWindow.opera;
if (/iPad|iPhone|iPod/.test(userAgent) && !unknownWindow.MSStream) return true;
return false;
}

const iphone = isIphone();
if(iphone) {
setTimeout(() => {
location.href = appStoreUrl;
}, 50);
}
setIsIphone(iphone);
}, []);
return <>
{!isIphone ? <span>iPhone만 접근할 수 있습니다.</span> : <span>AppStore로 이동중..<br/><a href={appStoreUrl}>직접 이동하기</a></span>}
</>;
}
3 changes: 3 additions & 0 deletions app/o/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <a>개발자</a>;
}

0 comments on commit 3828bb8

Please sign in to comment.