feat(apps): update mobile app store links and implement unified device-detecting QR code
This commit is contained in:
@@ -38,3 +38,9 @@ ALLOWED_ORIGIN=http://localhost:3000
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
NEXT_PUBLIC_TURNSTILE_SITE_KEY=your_cloudflare_turnstile_site_key
|
NEXT_PUBLIC_TURNSTILE_SITE_KEY=your_cloudflare_turnstile_site_key
|
||||||
CLOUDFLARE_TURNSTILE_SECRET_KEY=your_cloudflare_turnstile_secret_key
|
CLOUDFLARE_TURNSTILE_SECRET_KEY=your_cloudflare_turnstile_secret_key
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Mobile App Redirect Host override (optional - defaults to current origin / SITE_URL)
|
||||||
|
# Used for single smart QR code device routing to Google Play & App Store
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# NEXT_PUBLIC_APP_REDIRECT_HOST=https://your-public-domain.com
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
"slug": "bg-cleaner-app",
|
"slug": "bg-cleaner-app",
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Magic Cutout & Erase Studio",
|
"en": "BG Remove: Background Editor",
|
||||||
"hi": "मैजिक कटआउट और इरेज़ स्टूडियो"
|
"hi": "BG Remove: Background Editor"
|
||||||
},
|
},
|
||||||
"tagline": {
|
"tagline": {
|
||||||
"en": "Cut out any subject, erase photobombers, and design product shots",
|
"en": "Cut out any subject, erase photobombers, and design product shots",
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
"stores": {
|
"stores": {
|
||||||
"android": {
|
"android": {
|
||||||
"packageId": "com.creinnovations.bgcleaner",
|
"packageId": "com.me2creative.AiDressChanger",
|
||||||
"url": "https://play.google.com/store/apps/details?id=com.creinnovations.bgcleaner"
|
"url": "https://play.google.com/store/apps/details?id=com.me2creative.AiDressChanger&pcampaignid=web_share"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios": {
|
||||||
"appId": "1672384912",
|
"appId": "1497878283",
|
||||||
"url": "https://apps.apple.com/app/id1672384912"
|
"url": "https://apps.apple.com/bn/app/bg-remove-background-editor/id1497878283"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deepLink": {
|
"deepLink": {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
"slug": "photo-enhancer-pro",
|
"slug": "photo-enhancer-pro",
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Enhance Ultra AI",
|
"en": "Enhance Photo Quality",
|
||||||
"hi": "एन्हांस अल्ट्रा एआई"
|
"hi": "Enhance Photo Quality"
|
||||||
},
|
},
|
||||||
"tagline": {
|
"tagline": {
|
||||||
"en": "Turn blurry or aged photos into crystal clear 4K masterpieces",
|
"en": "Turn blurry or aged photos into crystal clear 4K masterpieces",
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
"stores": {
|
"stores": {
|
||||||
"android": {
|
"android": {
|
||||||
"packageId": "com.creinnovations.photoenhancer",
|
"packageId": "com.smartworld.enhancephotoquality",
|
||||||
"url": "https://play.google.com/store/apps/details?id=com.creinnovations.photoenhancer"
|
"url": "https://play.google.com/store/apps/details?id=com.smartworld.enhancephotoquality&pcampaignid=web_share"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios": {
|
||||||
"appId": "1672384911",
|
"appId": "1587310121",
|
||||||
"url": "https://apps.apple.com/app/id1672384911"
|
"url": "https://apps.apple.com/mm/app/enhance-photo-quality/id1587310121"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deepLink": {
|
"deepLink": {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
"slug": "bg-cleaner-app",
|
"slug": "bg-cleaner-app",
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Magic Cutout & Erase Studio",
|
"en": "BG Remove: Background Editor",
|
||||||
"hi": "\u092e\u0948\u091c\u093f\u0915 \u0915\u091f\u0906\u0909\u091f \u0914\u0930 \u0907\u0930\u0947\u091c\u093c \u0938\u094d\u091f\u0942\u0921\u093f\u092f\u094b"
|
"hi": "BG Remove: Background Editor"
|
||||||
},
|
},
|
||||||
"tagline": {
|
"tagline": {
|
||||||
"en": "Cut out any subject, erase photobombers, and design product shots",
|
"en": "Cut out any subject, erase photobombers, and design product shots",
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
"stores": {
|
"stores": {
|
||||||
"android": {
|
"android": {
|
||||||
"packageId": "com.creinnovations.bgcleaner",
|
"packageId": "com.me2creative.AiDressChanger",
|
||||||
"url": "https://play.google.com/store/apps/details?id=com.creinnovations.bgcleaner"
|
"url": "https://play.google.com/store/apps/details?id=com.me2creative.AiDressChanger&pcampaignid=web_share"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios": {
|
||||||
"appId": "1672384912",
|
"appId": "1497878283",
|
||||||
"url": "https://apps.apple.com/app/id1672384912"
|
"url": "https://apps.apple.com/bn/app/bg-remove-background-editor/id1497878283"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deepLink": {
|
"deepLink": {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
"slug": "photo-enhancer-pro",
|
"slug": "photo-enhancer-pro",
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Enhance Ultra AI",
|
"en": "Enhance Photo Quality",
|
||||||
"hi": "\u090f\u0928\u094d\u0939\u093e\u0902\u0938 \u0905\u0932\u094d\u091f\u094d\u0930\u093e \u090f\u0906\u0908"
|
"hi": "Enhance Photo Quality"
|
||||||
},
|
},
|
||||||
"tagline": {
|
"tagline": {
|
||||||
"en": "Turn blurry or aged photos into crystal clear 4K masterpieces",
|
"en": "Turn blurry or aged photos into crystal clear 4K masterpieces",
|
||||||
@@ -16,12 +16,12 @@
|
|||||||
},
|
},
|
||||||
"stores": {
|
"stores": {
|
||||||
"android": {
|
"android": {
|
||||||
"packageId": "com.creinnovations.photoenhancer",
|
"packageId": "com.smartworld.enhancephotoquality",
|
||||||
"url": "https://play.google.com/store/apps/details?id=com.creinnovations.photoenhancer"
|
"url": "https://play.google.com/store/apps/details?id=com.smartworld.enhancephotoquality&pcampaignid=web_share"
|
||||||
},
|
},
|
||||||
"ios": {
|
"ios": {
|
||||||
"appId": "1672384911",
|
"appId": "1587310121",
|
||||||
"url": "https://apps.apple.com/app/id1672384911"
|
"url": "https://apps.apple.com/mm/app/enhance-photo-quality/id1587310121"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deepLink": {
|
"deepLink": {
|
||||||
|
|||||||
@@ -7,39 +7,44 @@ export async function GET(
|
|||||||
req: NextRequest,
|
req: NextRequest,
|
||||||
{ params }: { params: { tool: string; app: string } }
|
{ params }: { params: { tool: string; app: string } }
|
||||||
) {
|
) {
|
||||||
const tool = getToolBySlug(params.tool) || getToolById(params.tool);
|
try {
|
||||||
const app = getAppBySlug(params.app) || getAppById(params.app);
|
const tool = getToolBySlug(params.tool) || getToolById(params.tool);
|
||||||
|
const app = getAppBySlug(params.app) || getAppById(params.app);
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
return NextResponse.redirect(new URL('/apps', req.url));
|
return NextResponse.redirect(new URL('/apps', req.url));
|
||||||
|
}
|
||||||
|
|
||||||
|
const userAgent = req.headers.get('user-agent') || '';
|
||||||
|
const isAndroid = /android/i.test(userAgent);
|
||||||
|
const isIOS = /ipad|iphone|ipod/i.test(userAgent);
|
||||||
|
|
||||||
|
const searchParams = req.nextUrl.searchParams;
|
||||||
|
const source = searchParams.get('utm_source') || 'web_try';
|
||||||
|
const campaign = searchParams.get('utm_campaign') || (tool ? tool.slug : 'general');
|
||||||
|
|
||||||
|
if (isAndroid) {
|
||||||
|
const playUrl = app.stores.android?.url || 'https://play.google.com';
|
||||||
|
const finalUrl = new URL(playUrl);
|
||||||
|
finalUrl.searchParams.set('referrer', `utm_source=${source}&utm_campaign=${campaign}`);
|
||||||
|
return NextResponse.redirect(finalUrl.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isIOS) {
|
||||||
|
const iosUrl = app.stores.ios?.url || 'https://apps.apple.com';
|
||||||
|
const finalUrl = new URL(iosUrl);
|
||||||
|
finalUrl.searchParams.set('pt', '123456');
|
||||||
|
finalUrl.searchParams.set('ct', `${source}_${campaign}`);
|
||||||
|
return NextResponse.redirect(finalUrl.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop visitor -> Redirect to app page with QR code & deep link info
|
||||||
|
const desktopUrl = new URL(`/apps/${app.slug}`, req.url);
|
||||||
|
desktopUrl.searchParams.set('src', source);
|
||||||
|
desktopUrl.searchParams.set('tool', tool ? tool.slug : '');
|
||||||
|
return NextResponse.redirect(desktopUrl.toString());
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('[go route error]', err);
|
||||||
|
return NextResponse.json({ error: err?.message || String(err) }, { status: 500 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userAgent = req.headers.get('user-agent') || '';
|
|
||||||
const isAndroid = /android/i.test(userAgent);
|
|
||||||
const isIOS = /ipad|iphone|ipod/i.test(userAgent);
|
|
||||||
|
|
||||||
const searchParams = req.nextUrl.searchParams;
|
|
||||||
const source = searchParams.get('utm_source') || 'web_try';
|
|
||||||
const campaign = searchParams.get('utm_campaign') || (tool ? tool.slug : 'general');
|
|
||||||
|
|
||||||
if (isAndroid) {
|
|
||||||
const playUrl = app.stores.android?.url || 'https://play.google.com';
|
|
||||||
const finalUrl = new URL(playUrl);
|
|
||||||
finalUrl.searchParams.set('referrer', `utm_source=${source}&utm_campaign=${campaign}`);
|
|
||||||
return NextResponse.redirect(finalUrl.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isIOS) {
|
|
||||||
const iosUrl = app.stores.ios?.url || 'https://apps.apple.com';
|
|
||||||
const finalUrl = new URL(iosUrl);
|
|
||||||
finalUrl.searchParams.set('pt', '123456');
|
|
||||||
finalUrl.searchParams.set('ct', `${source}_${campaign}`);
|
|
||||||
return NextResponse.redirect(finalUrl.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Desktop visitor -> Redirect to app page with QR code & deep link info
|
|
||||||
const desktopUrl = new URL(`/apps/${app.slug}`, req.url);
|
|
||||||
desktopUrl.searchParams.set('src', source);
|
|
||||||
desktopUrl.searchParams.set('tool', tool ? tool.slug : '');
|
|
||||||
return NextResponse.redirect(desktopUrl.toString());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,21 @@ export function AppHandoffSection({
|
|||||||
|
|
||||||
if (!app) return null;
|
if (!app) return null;
|
||||||
|
|
||||||
const baseHost = origin || 'http://localhost:3000';
|
const androidUrl = app.stores?.android?.url || 'https://play.google.com';
|
||||||
|
const iosUrl = app.stores?.ios?.url || 'https://apps.apple.com';
|
||||||
|
|
||||||
|
const redirectHost =
|
||||||
|
process.env.NEXT_PUBLIC_APP_REDIRECT_HOST ||
|
||||||
|
process.env.NEXT_PUBLIC_SITE_URL ||
|
||||||
|
origin ||
|
||||||
|
'http://localhost:3000';
|
||||||
|
|
||||||
const targetUrl = tool
|
const targetUrl = tool
|
||||||
? `${baseHost}/go/${tool.slug}/${app.slug}`
|
? `${redirectHost}/go/${tool.slug}/${app.slug}`
|
||||||
: `${baseHost}/apps/${app.slug}`;
|
: `${redirectHost}/go/explore/${app.slug}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showQr) {
|
if (showQr && targetUrl) {
|
||||||
QRCode.toDataURL(targetUrl, {
|
QRCode.toDataURL(targetUrl, {
|
||||||
width: 220,
|
width: 220,
|
||||||
margin: 1,
|
margin: 1,
|
||||||
@@ -132,7 +140,7 @@ export function AppHandoffSection({
|
|||||||
<span className="text-xs text-muted font-body block">Direct store installation</span>
|
<span className="text-xs text-muted font-body block">Direct store installation</span>
|
||||||
<div className="flex flex-col sm:flex-row flex-wrap gap-3">
|
<div className="flex flex-col sm:flex-row flex-wrap gap-3">
|
||||||
<a
|
<a
|
||||||
href={app.stores?.ios?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
href={iosUrl}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
||||||
@@ -143,7 +151,7 @@ export function AppHandoffSection({
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href={app.stores?.android?.url || `/go/${tool?.slug || 'explore'}/${app.slug}`}
|
href={androidUrl}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
||||||
@@ -157,7 +165,7 @@ export function AppHandoffSection({
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={copyLink}
|
onClick={copyLink}
|
||||||
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
className="btn-secondary min-h-[48px] rounded-full justify-center w-full sm:w-auto"
|
||||||
aria-label="Copy direct deep link"
|
aria-label="Copy smart redirect link"
|
||||||
>
|
>
|
||||||
{copiedLink ? <Check className="w-4 h-4 text-accent" aria-hidden="true" /> : <Copy className="w-4 h-4 text-muted" aria-hidden="true" />}
|
{copiedLink ? <Check className="w-4 h-4 text-accent" aria-hidden="true" /> : <Copy className="w-4 h-4 text-muted" aria-hidden="true" />}
|
||||||
<span>{copiedLink ? 'Link copied' : 'Copy link'}</span>
|
<span>{copiedLink ? 'Link copied' : 'Copy link'}</span>
|
||||||
@@ -170,22 +178,28 @@ export function AppHandoffSection({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right Column: Clean QR Code Card */}
|
{/* Right Column: Single Smart QR Code Card */}
|
||||||
{showQr && qrDataUrl && (
|
{showQr && qrDataUrl && (
|
||||||
<div className="lg:col-span-5 studio-sheet rounded-3xl p-6 sm:p-8 text-center flex flex-col items-center">
|
<div className="lg:col-span-5 studio-sheet rounded-3xl p-6 sm:p-8 text-center flex flex-col items-center">
|
||||||
<span className="text-xs text-muted font-body mb-4">Scan with phone camera</span>
|
<span className="text-xs text-muted font-body mb-3 font-semibold uppercase tracking-wider">
|
||||||
|
Scan with Phone Camera
|
||||||
|
</span>
|
||||||
|
|
||||||
<div className="p-4 bg-paper-hi border border-rule rounded-2xl inline-block shadow-sm">
|
<div className="p-4 bg-paper-hi border border-rule rounded-2xl inline-block shadow-sm">
|
||||||
<img
|
<img
|
||||||
src={qrDataUrl}
|
src={qrDataUrl}
|
||||||
alt={`Scan QR code to install ${appName}`}
|
alt={`Scan single QR code to open ${appName}`}
|
||||||
className="w-44 h-44 object-contain rounded-xl"
|
className="w-44 h-44 object-contain rounded-xl"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-4 space-y-1 text-xs font-body text-muted">
|
<div className="mt-4 space-y-1.5 text-xs font-body text-muted">
|
||||||
<p className="font-medium text-ink">Instant mobile handoff</p>
|
<p className="font-semibold text-ink flex items-center justify-center gap-1.5">
|
||||||
<p>Directs to App Store or Google Play for instantaneous installation.</p>
|
<span>⚡ Automatic Store Detection</span>
|
||||||
|
</p>
|
||||||
|
<p className="text-[11.5px] text-muted max-w-xs leading-relaxed">
|
||||||
|
Single QR code — automatically opens <strong>Google Play</strong> on Android or <strong>Apple App Store</strong> on iPhone.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ const DEFAULT_RECOMMENDED_APPS = [
|
|||||||
{
|
{
|
||||||
id: 'app-enhancer',
|
id: 'app-enhancer',
|
||||||
slug: 'photo-enhancer-pro',
|
slug: 'photo-enhancer-pro',
|
||||||
name: 'Enhance Ultra AI',
|
name: 'Enhance Photo Quality',
|
||||||
tagline: 'Generative 4K super-resolution and archival restoration',
|
tagline: 'Generative 4K super-resolution and archival restoration',
|
||||||
category: 'Super resolution',
|
category: 'Super resolution',
|
||||||
platforms: ['iOS 17+', 'Android 14+'],
|
platforms: ['iOS 17+', 'Android 14+'],
|
||||||
@@ -104,7 +104,7 @@ const DEFAULT_RECOMMENDED_APPS = [
|
|||||||
{
|
{
|
||||||
id: 'app-cutout',
|
id: 'app-cutout',
|
||||||
slug: 'bg-cleaner-app',
|
slug: 'bg-cleaner-app',
|
||||||
name: 'Magic Cutout Studio',
|
name: 'BG Remove: Background Editor',
|
||||||
tagline: 'Sub-pixel P3M alpha matting and background removal',
|
tagline: 'Sub-pixel P3M alpha matting and background removal',
|
||||||
category: 'Background cutout',
|
category: 'Background cutout',
|
||||||
platforms: ['iOS 17+', 'Android 14+'],
|
platforms: ['iOS 17+', 'Android 14+'],
|
||||||
|
|||||||
@@ -77,23 +77,33 @@ export function PostResultAppHandoff({
|
|||||||
const appName = resolveLocalised(appData.name, locale);
|
const appName = resolveLocalised(appData.name, locale);
|
||||||
const toolName = tool.name ? resolveLocalised(tool.name, locale) : 'Photo Tools';
|
const toolName = tool.name ? resolveLocalised(tool.name, locale) : 'Photo Tools';
|
||||||
|
|
||||||
const baseHost = origin || 'http://localhost:3000';
|
const redirectHost =
|
||||||
const targetUrl = `${baseHost}/go/${tool.slug}/${appData.slug}?src=${variant}`;
|
process.env.NEXT_PUBLIC_APP_REDIRECT_HOST ||
|
||||||
const iosUrl = appData.stores?.ios?.url || `/go/${tool.slug}/${appData.slug}?src=ios`;
|
process.env.NEXT_PUBLIC_SITE_URL ||
|
||||||
const androidUrl = appData.stores?.android?.url || `/go/${tool.slug}/${appData.slug}?src=android`;
|
origin ||
|
||||||
|
'http://localhost:3000';
|
||||||
|
|
||||||
|
const targetUrl = tool
|
||||||
|
? `${redirectHost}/go/${tool.slug}/${appData.slug}?src=${variant}`
|
||||||
|
: `${redirectHost}/go/explore/${appData.slug}?src=${variant}`;
|
||||||
|
|
||||||
|
const iosUrl = appData.stores?.ios?.url || 'https://apps.apple.com';
|
||||||
|
const androidUrl = appData.stores?.android?.url || 'https://play.google.com';
|
||||||
|
|
||||||
// Generate dynamic QR Code for instant phone handoff
|
// Generate dynamic QR Code for instant phone handoff
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
QRCode.toDataURL(targetUrl, {
|
if (targetUrl) {
|
||||||
width: 240,
|
QRCode.toDataURL(targetUrl, {
|
||||||
margin: 1,
|
width: 240,
|
||||||
color: {
|
margin: 1,
|
||||||
dark: '#0f172a',
|
color: {
|
||||||
light: '#ffffff',
|
dark: '#0f172a',
|
||||||
},
|
light: '#ffffff',
|
||||||
})
|
},
|
||||||
.then((url) => setQrDataUrl(url))
|
})
|
||||||
.catch((err) => console.error('Failed to generate QR code:', err));
|
.then((url) => setQrDataUrl(url))
|
||||||
|
.catch((err) => console.error('Failed to generate QR code:', err));
|
||||||
|
}
|
||||||
}, [targetUrl]);
|
}, [targetUrl]);
|
||||||
|
|
||||||
const handleCopyLink = (e: React.MouseEvent) => {
|
const handleCopyLink = (e: React.MouseEvent) => {
|
||||||
@@ -315,7 +325,7 @@ export function PostResultAppHandoff({
|
|||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
<img
|
<img
|
||||||
src={qrDataUrl}
|
src={qrDataUrl}
|
||||||
alt={`Scan QR code to install ${appName}`}
|
alt={`Scan single QR code to install ${appName}`}
|
||||||
className="w-40 h-40 object-contain rounded-xl select-none"
|
className="w-40 h-40 object-contain rounded-xl select-none"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@@ -326,12 +336,12 @@ export function PostResultAppHandoff({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p className="text-[11px] text-slate-600 font-sans leading-tight">
|
<p className="text-[11.5px] text-slate-800 font-sans font-semibold leading-tight">
|
||||||
Instantly opens App Store or Google Play directly on your phone.
|
⚡ Automatic Store Detection
|
||||||
|
</p>
|
||||||
|
<p className="text-[11px] text-slate-500 font-sans leading-relaxed">
|
||||||
|
Automatically opens <strong>Google Play</strong> on Android or <strong>App Store</strong> on iPhone.
|
||||||
</p>
|
</p>
|
||||||
<span className="inline-block text-[10px] text-slate-400 font-sans">
|
|
||||||
Works on iOS 15+ and Android 9+
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { NextRequest } from 'next/server';
|
||||||
|
import { GET } from '@/app/go/[tool]/[app]/route';
|
||||||
|
|
||||||
|
describe('/go/[tool]/[app] dynamic redirect route', () => {
|
||||||
|
it('redirects Android user to Enhance Photo Quality on Google Play', async () => {
|
||||||
|
const req = new NextRequest('http://localhost:3000/go/photo-enhancer/photo-enhancer-pro', {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 Chrome/120.0.0.0 Mobile Safari/537.36',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await GET(req, {
|
||||||
|
params: { tool: 'photo-enhancer', app: 'photo-enhancer-pro' },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.status).toBe(307);
|
||||||
|
const location = res.headers.get('location');
|
||||||
|
expect(location).toContain('play.google.com/store/apps/details?id=com.smartworld.enhancephotoquality');
|
||||||
|
expect(location).toContain('pcampaignid=web_share');
|
||||||
|
expect(location).toContain('referrer=utm_source');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('redirects iOS user to Enhance Photo Quality on Apple App Store', async () => {
|
||||||
|
const req = new NextRequest('http://localhost:3000/go/photo-enhancer/photo-enhancer-pro', {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await GET(req, {
|
||||||
|
params: { tool: 'photo-enhancer', app: 'photo-enhancer-pro' },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.status).toBe(307);
|
||||||
|
const location = res.headers.get('location');
|
||||||
|
expect(location).toContain('apps.apple.com/mm/app/enhance-photo-quality/id1587310121');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('redirects Android user to BG Remove / Dress Changer on Google Play', async () => {
|
||||||
|
const req = new NextRequest('http://localhost:3000/go/background-remover/bg-cleaner-app', {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Mozilla/5.0 (Linux; Android 14; Samsung Galaxy S24) AppleWebKit/537.36',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await GET(req, {
|
||||||
|
params: { tool: 'background-remover', app: 'bg-cleaner-app' },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.status).toBe(307);
|
||||||
|
const location = res.headers.get('location');
|
||||||
|
expect(location).toContain('play.google.com/store/apps/details?id=com.me2creative.AiDressChanger');
|
||||||
|
expect(location).toContain('pcampaignid=web_share');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('redirects iOS user to BG Remove: Background Editor on Apple App Store', async () => {
|
||||||
|
const req = new NextRequest('http://localhost:3000/go/background-remover/bg-cleaner-app', {
|
||||||
|
headers: {
|
||||||
|
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await GET(req, {
|
||||||
|
params: { tool: 'background-remover', app: 'bg-cleaner-app' },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.status).toBe(307);
|
||||||
|
const location = res.headers.get('location');
|
||||||
|
expect(location).toContain('apps.apple.com/bn/app/bg-remove-background-editor/id1497878283');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user