feat: updated logic
This commit is contained in:
@@ -7,39 +7,39 @@ export default function SharePage({ params }: { params: { code: string } }) {
|
||||
const code = params.code;
|
||||
|
||||
useEffect(() => {
|
||||
const deepLink = "nemia://share/" + code;
|
||||
const playStoreLink = "https://play.google.com/store/apps/details?id=app.nemia.android";
|
||||
const waitlistLink = "https://nemia.app/waitlist";
|
||||
const landingPage = "https://nemia.app";
|
||||
try {
|
||||
const deepLink = "nemia://share/" + code;
|
||||
const playStoreLink = "https://play.google.com/store/apps/details?id=app.nemia.android";
|
||||
const waitlistLink = "https://nemia.app/waitlist";
|
||||
const landingPage = "https://nemia.app";
|
||||
|
||||
const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;
|
||||
const userAgent = navigator.userAgent || navigator.vendor || (window as any).opera;
|
||||
|
||||
// iOS Detection
|
||||
if (/iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream) {
|
||||
window.location.href = waitlistLink;
|
||||
return;
|
||||
// iOS Detection
|
||||
if (/iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream) {
|
||||
window.location.href = waitlistLink;
|
||||
return;
|
||||
}
|
||||
|
||||
// Android Detection
|
||||
if (/android/i.test(userAgent)) {
|
||||
// Try to open the app via Intent Scheme
|
||||
// Fallback to Play Store if app not installed
|
||||
const intentUrl =
|
||||
"intent://share/" +
|
||||
code +
|
||||
"#Intent;scheme=nemia;package=app.nemia.android;S.browser_fallback_url=" +
|
||||
encodeURIComponent(playStoreLink) +
|
||||
";end";
|
||||
window.location.href = intentUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Desktop / Other: Stay on the page
|
||||
} catch (e) {
|
||||
console.error("Redirection error:", e);
|
||||
window.location.href = `/?error=${encodeURIComponent("An error occurred while redirecting.")}`;
|
||||
}
|
||||
|
||||
// Android Detection
|
||||
if (/android/i.test(userAgent)) {
|
||||
// Try to open the app via Intent Scheme
|
||||
const intentUrl =
|
||||
"intent://share/" +
|
||||
code +
|
||||
"#Intent;scheme=nemia;package=app.nemia.android;S.browser_fallback_url=" +
|
||||
encodeURIComponent(landingPage) +
|
||||
";end";
|
||||
window.location.href = intentUrl;
|
||||
|
||||
// Fallback attempt (optional, if intent fails)
|
||||
// setTimeout(() => {
|
||||
// window.location.href = playStoreLink;
|
||||
// }, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Desktop / Other: Stay on the page or redirect to landing
|
||||
// window.location.href = landingPage;
|
||||
}, [code]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user