From 7205ed9114d2ea4c3a493575500c6b23f3ddb873 Mon Sep 17 00:00:00 2001 From: Elliott Kember Date: Fri, 16 Jul 2021 10:00:38 -0700 Subject: [PATCH] Broke app redirect --- src/main/AppRedirect.js | 39 +++++++++++++++++++++++++++++++++++++++ src/main/ide.js | 4 ++++ 2 files changed, 43 insertions(+) create mode 100644 src/main/AppRedirect.js diff --git a/src/main/AppRedirect.js b/src/main/AppRedirect.js new file mode 100644 index 0000000..526ab50 --- /dev/null +++ b/src/main/AppRedirect.js @@ -0,0 +1,39 @@ +import { useEffect } from "react"; + +function getMobileOperatingSystem() { + var userAgent = navigator.userAgent || navigator.vendor || window.opera; + // Windows Phone must come first because its UA also contains "Android" + if (/windows phone/i.test(userAgent)) { + return "Windows Phone"; + } + if (/android/i.test(userAgent)) { + return "Android"; + } + // iOS detection from: http://stackoverflow.com/a/9039885/177710 + if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { + return "iOS"; + } + return "unknown"; +} + +const AppRedirect = () => { + useEffect(() => { + var os = getMobileOperatingSystem(); + switch (os) { + case "Android": + window.location = "google.com"; + break; + case "iOS": + window.location = + "https://apps.apple.com/us/app/soulmate-lights/id1330064071"; + break; + default: + window.location = "/"; + break; + } + }, []); + + return <>; +}; + +export default AppRedirect; diff --git a/src/main/ide.js b/src/main/ide.js index 18ccba7..c241df3 100644 --- a/src/main/ide.js +++ b/src/main/ide.js @@ -18,6 +18,7 @@ import Logo from "~/images/logo.svg"; import history from "~/utils/history"; import isElectron from "~/utils/isElectron"; +import AppRedirect from "./AppRedirect"; import ErrorBoundary from "./components/ErrorBoundary"; import Config from "./config"; import Console from "./console"; @@ -70,6 +71,9 @@ const IDE = () => { + + +