Get the default iOS user agent for HTTP requests

I am communicating with an API that requires me to use a specific user-agent string. The format for this is basicallyUser-Agent: IOS_USER_AGENT API_CUSTOM_AGENT

After investigating, I found that people would use UIWebViewand use the javascript function to retrieve the system user agent string. Now that it is UIWebViewdeprecated, its replacement WKWebViewoffers an asynchronous means of computing the user agent (not ideal for my purposes).

Is there a way to extract some form of iOS user agent string without having to accidentally create some on-screen web view. Especially since SFSafariViewControllerI don’t think it’s completely impossible that these web views will become obsolete in the future.

I know that apps like WhatsApp and Facebook use the system User-Agent see here . The question is, what is the most reliable way to achieve this without involving web presentation tricks?

+4
source share

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


All Articles