We send people links that end on a Google review form. A lot of those links are opened from Telegram, Viber and Instagram, and every one of these apps opens them in its own in-app browser. That browser is usually not signed in to Google, so instead of the review form the user sees a login screen and leaves.

So we needed a way to move the user from the in-app webview to a real browser (or straight to the Google Maps app). Here's what we ended up with after testing on real phones, including the parts that don't work.

Step 1: figure out where you are

Detection is User-Agent based, and it's messier than it should be.

export function detectApp(ua: string): App { if (/Barcelona/i.test(ua)) return "threads"; // Threads' internal codename if (/Instagram/i.test(ua)) return "instagram"; if (/FBAN|FBAV/i.test(ua)) return "facebook"; if (/Viber/i.test(ua)) return "viber"; if (/IABMV/i.test(ua)) return "facebook"; // catches Meta rebrands/regional variants return "unknown"; // Telegram has no reliable UA signature } 

Two things we learned:

  • Telegram doesn't identify itself. There is no stable marker in its UA on iOS or Android, so it falls into "unknown". That's fine, because the escape that works for Telegram is safe to try on unknown webviews too.
  • On Android, ; wv) in the UA means webview. On iOS there's no such flag, so we treat any iOS UA without Version/ (which Safari has) as a webview. Getting this wrong in the safe direction just means showing an extra hint; getting it wrong the other way means a dead end.

Step 2 (Android): a chain of intents

Android lets a page navigate to an intent:// URL, which asks the system to open the link in another app. We try three targets in order:

  1. Google Maps app — this one is an experiment we're still checking on devices. The idea: if Maps accepts the review link, the user gets the native review sheet, which would be the shortest path to a posted review. If it doesn't, the step costs 1.5 seconds and nothing else.
  2. Chrome — present on almost every Android phone.
  3. Any app that handles https — no package specified.
export function buildAndroidIntentUrl(targetUrl: string, opts: { pkg?: string; browserFallback: boolean }) { const uri = targetUrl.replace(/^https:\/\//, ""); const parts = ["scheme=https"]; if (opts.pkg) parts.push(`package=${opts.pkg}`); parts.push("action=android.intent.action.VIEW"); if (opts.browserFallback) parts.push(`S.browser_fallback_url=${encodeURIComponent(targetUrl)}`); return `intent://${uri}#Intent;${parts.join(";")};end`; } 

Details that cost us time:

  • No browser_fallback_url on the Maps step. If the intent can't be resolved, the fallback URL is opened in the current browser, which is the in-app webview you're trying to leave. The Google page would load inside Instagram and the chain would be over. So the Maps step fails silently instead, and the next step runs.
  • Strip the #fragment from the target URL before building the intent. A fragment like #Intent;package=...;end inside the link would get appended to your intent.
  • You can't get a callback. The only sign that the escape worked is the page going to the background, so we listen for visibilitychange and move to the next step after a timeout (1.5 s for Maps, 2.5 s for the others) if the page is still visible.
  • If nothing worked, show a screen with a "copy link" button and instructions. Don't leave the user on a spinner.

Step 3 (iOS): x-safari-https://, and where it stops working

On iOS, replacing https:// with x-safari-https:// asks the system to open the link in Safari. It works from Telegram and Viber.

It does not work from Instagram, Threads or Facebook. We tried it and seven other techniques on real devices; none of them get out of Meta's in-app browser on iOS. The only working path is the user tapping the "⋯" menu and choosing "Open in browser". So for those apps we don't attempt anything automatic, and go straight to an overlay with an arrow pointing at the corner where that particular app puts its menu, plus a "copy link" button.

For Telegram, Viber and unknown webviews we try x-safari-https:// first and show the same overlay if the page is still here after 2.5 s. "Did we leave?" is inferred from any of visibilitychange, pagehide or blur.

const xSafari = targetUrl.replace(/^https:\/\//, "x-safari-https://"); let left = false; const markLeft = () => { left = true; }; document.addEventListener("visibilitychange", () => document.hidden && markLeft()); window.addEventListener("pagehide", markLeft, { once: true }); window.addEventListener("blur", markLeft, { once: true }); setTimeout(() => { if (!left) showOverlay(); }, 2500); location.href = xSafari; 

One more thing we tested and dropped: the iOS share sheet (Web Share API) from inside a webview doesn't offer "Open in Safari", so it's not a way out.

Small things that matter

  • Wait about a second before the escape attempt. If you navigate in the same tick as the click, the "Opening the review page…" spinner never paints, and the user sees a frozen screen.
  • Re-check whether the user already left before each step. People close the tab or switch apps during the pause, and firing an intent after that is just noise.
  • Track every exit path once. Desktop, Android and iOS all leave the page differently; dedupe your "redirect" analytics event or you'll double count.
  • Test on phones, not emulators. None of this reproduces locally. We open a tunnel to the dev server and tap the link from inside each messenger.

Summary

Where the link is opened What works
Android, any messenger intent:// chain: Maps (experimental) → Chrome → any https handler → copy-link screen
iOS, Telegram / Viber x-safari-https://, overlay if it didn't leave
iOS, Instagram / Threads / Facebook Nothing automatic. Overlay pointing at the "⋯" menu + copy link

This is part of the review page in Pochuto, a tool that helps local businesses collect Google reviews through QR codes and personal links. If you've found a way out of Instagram's in-app browser on iOS that we missed, I'd really like to hear about it in the comments.