2

I have a website that is built with reactJs. I have built a mobile version not using react native but this:

import React from "react";
import { WebView } from "react-native-webview";
export default function App() {
  return (
    <WebView
      source={{ uri: "https://mywebsiteurl" }}
      style={{ marginTop: 20, backgroundColor: "transparent" }}
    />
  );
}

Now I want to detect whether the app is running on a browser or mobile app from inside my web reactJS code.

N.B : I do not want to differentiate between mobile browser and web browser. I want to detect whether browser(any browser of windows/MacOS/ubuntu/IOS/android/Smart tv) or mobile app(IOS/Android)

  • 3
    Same way you do it for pure js https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser – Arseniy-II Sep 24 '20 at 07:09
  • 2
    Does this answer your question? [Detecting a mobile browser](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) – Arseniy-II Sep 24 '20 at 07:09
  • In my case, it is no comparison between mobile browser and desktop browser. It is the comparison between browser(mobile/desktop/tv) and mobile app(Android/IOS) – Ehtesham Ahmad Nadim Sep 24 '20 at 07:12
  • Check this Mozilla doc https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Mobile_Device_Detection – Vaibhav Rai Sep 24 '20 at 07:14
  • 1
    @EhteshamAhmadNadim you either use react native or some alternative in that case it can be only mobile. Or you use js in that case you should have access to `navigator.userAgent` and [that answer](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) should be enough for you – Arseniy-II Sep 24 '20 at 07:19

0 Answers0