-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added app-store detctor for directing users to the right app store ba…
…sed on device OS, intended for when scanning an app QR Code
- Loading branch information
Quinn Patwardhan
committed
Jul 23, 2023
1 parent
9b5d01f
commit df170e3
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,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 ( | ||
<div> | ||
{IOS_LINK} - {ANDROID_LINK} | ||
</div> | ||
); | ||
} |