Skip to content

Commit

Permalink
Broke app redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottkember committed Jul 16, 2021
1 parent a4a284f commit 7205ed9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/AppRedirect.js
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions src/main/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -70,6 +71,9 @@ const IDE = () => {
<meta content="product" property="og:type" />
</Helmet>
<Switch>
<Route path="/app">
<AppRedirect />
</Route>
<Route path="/desktop-sign-in">
<Logo className="loading-spinner" />
</Route>
Expand Down

0 comments on commit 7205ed9

Please sign in to comment.