hellomello
hellomello

Reputation: 8585

Instagram links open in-app browser instead of external/native browser

If I have a link in my profile, the link opens up an in-app browser either from iOS or Android. Is it possible to open up an external browser instead? Possibly in my own site, if I can detect if user uses mobile, open native browser? Perhaps this is a solution with javascript?

The issue is because users who are logged into my site, and then click on the link within Instagram the in-app browser doesn't keep the user logged in.

Upvotes: 5

Views: 8772

Answers (1)

Sasan Salem
Sasan Salem

Reputation: 159

That’s possible and simple!
you must cheat the Instagram’s in-app browser. The weakness point of Instagram’s in-app browser is file downloading. When you ask it to download a file, it invokes an external browser and this is our golden key.

You first need to check which browser has your customer come to your website with.
In other words:

<script>
   if(navigator.userAgent.includes("Instagram")){
       window.location.href = "https://mywebsite.com/DummyBytes";
   }
</script>

Then, implement the DummyBytes API. This API returns a different response based on the viewer’s browser. If the viewer’s browser is Instagram’s in-app browser, it will return some dummy bytes as a file, otherwise it will return a response that redirects the viewer’s browser to your main website (mywebsite.com)

<?php
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    if (strpos($userAgent, 'Instagram')) {
        header('Content-type: application/pdf');
        header('Content-Disposition: inline; filename= blablabla');
        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');
        @readfile($file);
    }
    else{
        header('Location: https://halterapp.com');
    }
?>

If you want more guidance, see link below:
Opening of your website in the viewer’s external browser automatically instead of Instagram’s in-app browser

Upvotes: 8

Related Questions