0

I'm using npm package like Bowser to detect the Browser that I'm using when I'm opening a link. but When I try to open the link in my messenger. It still says that I'm using Chrome, but I'm on Facebook In-app Browser.

Is there any package to detect if using Facebook In-app Browser

Pinky Promise
  • 229
  • 3
  • 18

1 Answers1

1

you can just create a helper function to do so:


const isFacebookInAppBrowser = () => /FB_IAB/.test(navigator.userAgent) ||
  /FBAN/.test(navigator.userAgent) ||
  /FBAV/.test(navigator.userAgent);

This works for facebook in app but I am not sure for messenger. I didn't even know that it had a browser.

A. Llorente
  • 1,142
  • 6
  • 16
  • hello, would like to ask. how can I check this when I'm in fb in-app browser? it's false when I'm in chrome but I can't seem to check if I'm in fb in-app browser – Pinky Promise Nov 23 '21 at 04:45
  • 1
    this is part of your code so you just run it where you need it... your app is running on a browser so you can invoke that function as you would invoke any other. I don't quite understand the question – A. Llorente Nov 23 '21 at 06:43
  • Hello for example I run that `{isFacebookApp == true ? (
    This is from Messenger Browser
    ) : (
    OTHER BROWSER
    )}` but when I tried opening it on facebook in app browser, it still shows chrome?
    – Pinky Promise Nov 23 '21 at 06:53
  • 1
    have you tried this? ```{/FB_IAB/.test(navigator.userAgent) || /FBAN/.test(navigator.userAgent) || /FBAV/.test(navigator.userAgent) ? (
    This is from Messenger Browser
    ) : (
    ```
    – A. Llorente Nov 23 '21 at 09:38
  • Hello just a follow-up question, how do you get the facebook in-app browser version? – Pinky Promise Dec 16 '21 at 06:13
  • Hi @PinkyPromise, have a look at the different user-agents that it uses, https://developers.whatismybrowser.com/useragents/explore/software_name/facebook-app/ I never had the need to check for version but you can find patterns there and look for the version ;) I hope it helps – A. Llorente Dec 16 '21 at 06:58