Responsive design when loading a page in an iOS app web application

I would like to know if the contents of a webpage can be adapted when loading from a specific web view of the application.

I was thinking about media queries, but: I want to have a different web design when the page loads in a mobile browser or in the web view of the application.

Is there something I can do to distinguish them, or do I need to change the web browsing user agent and thus differentiate the content?

+4
source share
2 answers

This SO question has the answer:

Web requests made from UIWebView will not contain the word "Safari" in the User Agent string. Web requests made from Mobile Safari. This is the best way I've found to identify a request coming from an application or from Mobile Safari.

Example user agent from

UIWebView within app: User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile 

Example user agent from Mobile Safari:

User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari

+2
source

You cannot make a web page responsive from UIWebview, there is only one way to use media queries to create a responsive website. You cannot change your native application.

0
source

Source: https://habr.com/ru/post/1489765/


All Articles