Obromios Obromios - 1 year ago 525
iOS Question

Set user agent withh WebView with react-native

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 source prop in the WebView.

How do I do this for IOS and Android?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download