Set user agent with WebView with react-native

后端 未结 9 1486
闹比i
闹比i 2021-02-19 13:26

I want to modify the user agent string in a WebView so that on the server side I can detect that the request has come from my react-native app. I want to do this using the sourc

9条回答
  •  甜味超标
    2021-02-19 13:51

    This is not an answer, but a workaround.

    I realised that what I wanted to do was determine if a request to my ruby on rails server was from mobile safari or from the webView of my react-native app. To solve this, I just installed the browser gem, and then did

    browser = Browser.new(request.user_agent)
    from_app = browser.platform.ios_webview?
    

    If someone can give a clear answer to my original question, I will select that answer rather than mine.

提交回复
热议问题