-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4a284f
commit 7205ed9
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters