diff --git a/package-lock.json b/package-lock.json index 602e95d..e6479fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@types/node": "^16.18.3", "@types/react": "^18.0.25", "@types/react-dom": "^18.0.9", + "platform": "^1.3.6", "react": "^18.2.0", "react-dom": "^18.2.0", "react-ga": "^3.3.1", @@ -12436,6 +12437,11 @@ "node": ">=4" } }, + "node_modules/platform": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", + "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==" + }, "node_modules/postcss": { "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", diff --git a/package.json b/package.json index 8cc288a..51aa032 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "@types/node": "^16.18.3", "@types/react": "^18.0.25", "@types/react-dom": "^18.0.9", + "platform": "^1.3.6", "react": "^18.2.0", "react-dom": "^18.2.0", "react-ga": "^3.3.1", diff --git a/src/App.tsx b/src/App.tsx index 3f17957..640d002 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,6 +20,7 @@ import Solutions from "./Pages/Solutions"; import Contact from "./Pages/Contact"; import { Helmet } from "react-helmet"; import Projects from "./Pages/Projects"; +import AppStoreRedirecter from "./Pages/AppStoreRedirecter"; function App() { return ( @@ -34,6 +35,10 @@ function App() { + } + /> } /> } /> } /> diff --git a/src/Pages/AppStoreRedirecter.tsx b/src/Pages/AppStoreRedirecter.tsx new file mode 100644 index 0000000..f6fb270 --- /dev/null +++ b/src/Pages/AppStoreRedirecter.tsx @@ -0,0 +1,33 @@ +import React, { useEffect } from "react"; +import { Routes, Route, useParams } from "react-router-dom"; + +export default function AppStoreRedirecter() { + let { IOS_LINK, ANDROID_LINK } = useParams(); + function detectMobileOS() { + const userAgent = navigator.userAgent; + if (/android/i.test(userAgent)) { + return "Android"; + } else if (/iPad|iPhone|iPod/i.test(userAgent)) { + return "iOS"; + } else { + return "Unknown"; + } + } + useEffect(() => { + console.log(IOS_LINK); + console.log(ANDROID_LINK); + if (detectMobileOS() === "iOS") { + window.location.replace(new URL(IOS_LINK ?? "")); + } else if (detectMobileOS() === "Android") { + window.location.replace(new URL(ANDROID_LINK ?? "")); + } else { + window.location.replace(new URL("https://quinnpatwardhan.com")); + } + }, []); + + return ( +
+ {IOS_LINK} - {ANDROID_LINK} +
+ ); +}