When http request comes to my server, how do I detect if it is from iphone, android, or other devices?
It works by examining information contained in the HTTP headers, particularly User Agent strings sent by all web-enabled devices. The User Agent is looked up in a database that returns any requested information including device type.
In summary, we recommend looking for the string “Mobi” anywhere in the User Agent to detect a mobile device. Like this: if (/Mobi/. test(navigator.
The User-Agent header contains a line of text that can be used to identify a user agent and client device. Most of the time, we can find the device model and manufacturer from the User-Agent header. It may also contain information such as the client device's OS version, browser version, Java capabilities, etc.
you can use below code, var index = navigator. appVersion. indexOf("Mobile");
You need to check the header of the HTTP request. You can find both the OS and the browser being used in the "User-Agent" field.
If you are using javascript then use the navigator
object
navigator.userAgent
If you are using php then you can access the HTTP header
$userAgent = $_SERVER["HTTP_USER_AGENT"];
You can grab the User Agent. That tells what browser type it is (iphone, chrome, ie, anything)
To help you:
http://whatsmyuseragent.com/
http://en.wikipedia.org/wiki/User_agent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With