0

I want specific keys so that i can make a distinction between the devices using user-agent string. 1. Laptop/Desktop 2. IOS 3. Android 4. Other handsets (BB, Nokia, MS Mobile)

kharevbv
  • 159
  • 1
  • 1
  • 12

1 Answers1

0

You can detect mobile devices using regular expressions on the User-Agent:

90% of the mobile devices can be detected using

/Mobile|Android|BlackBerry/

If you want to detect around 98% of mobile devices you can use this one:

/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/

You can use a subset of the last regex to target specific ones.

About detecting between desktop and laptop it is just NOT possible using user-agent. You need additional information that it is not in the UA such as macaddr or model name.

Adrian
  • 9,102
  • 4
  • 40
  • 35