Search code examples
androidgoogle-chromebrowserprogressive-web-appsnative

is it possible after native browser detection in your website to open it out in external browser


I got inspired by google maps , When it detects native browser it suggest to use it in app The detection process is simple but im not sure ,

The question is :

on ANDROID devices How i can force my website users to exit that native browser and open it in default(external) browser

Google Chrome:

googlechrome://domain

this is simple detection snippet

function isInFacebookApp() {
      return /FBAV/i.test(navigator.userAgent);
    }

if (isInFacebookApp()) {
  // do somthing window.open("https://my-website.com");
} else {
  console.log("native browser not detected");
}`

Solution

  • After testing for little bit i found this and its working just fine

    In my case android and default browser google-chrome

    // Use the 'intent:' link for Android

      if (/Android/i.test(navigator.userAgent)) {
        window.location.href = 'intent:https://your-website.com#Intent;end';
      } else {
        // For other platforms, use window.open with a fallback
        window.open('https://your-site.com');
      }