Skip to content

Commit

Permalink
if at first you dont succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Helfer committed Apr 25, 2024
1 parent c53ad21 commit 336e9cd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/Redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ import React, { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
import GooglePlayButton from '@theme/GooglePlayButton';
import AppStoreButton from '@theme/AppStoreButton';
import { useHistory } from 'react-router-dom';

const Redirect: React.FC = () => {
const [display, setDisplay] = useState('none');
const location = useLocation();
const params = new URLSearchParams(location.search);
const promoter = params.get('x') || 'threetenlabs';
const utmMedium = params.has('x') ? 'influencer' : 'website';
const [display, setDisplay] = useState('none');
const location = useLocation();
const history = useHistory();
const params = new URLSearchParams(location.search);
const promoter = params.get('x') || 'threetenlabs';
const utmMedium = params.has('x') ? 'influencer' : 'website';

const iOSUrl = `https://apps.apple.com/us/app/y-a-s-s/id6472488148?ct=2024install&pt=${promoter}`;
const androidUrl = `https://play.google.com/store/apps/details?id=com.threetenlabs.spidersolitaire&utm_source=threetenlabswebsite&utm_medium=${utmMedium}&utm_campaign=2024install&utm_content=${promoter}`;

const iOSUrl = `https://apps.apple.com/us/app/y-a-s-s/id6472488148?ct=2024install&pt=${promoter}`;
const androidUrl = `https://play.google.com/store/apps/details?id=com.threetenlabs.spidersolitaire&utm_source=threetenlabswebsite&utm_medium=${utmMedium}&utm_campaign=2024install&utm_content=${promoter}`;

useEffect(() => {
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
var isiOS = /iPad|iPhone|iPod/.test(ua);

if (isiOS) {
window.location.href = iOSUrl;
history.push(iOSUrl);
} else if (isAndroid) {
window.location.href = androidUrl;
history.push(androidUrl);
} else {
setDisplay('flex');
}
Expand Down

0 comments on commit 336e9cd

Please sign in to comment.