Search code examples
windowsuser-agentapex-codeapex

User agent check for Windows device


I'm using something similar to the following code snippet in my Apex controller to check if someone is accessing my website from an iPhone or Android phone.

userAgent.contains('iPhone') || ( userAgent.contains('Android') && userAgent.contains('Mobile'));

Can I use something similar to check if someone is using a Windows device?


Solution

  • According to the version of categorizr I have on hand, the following detects windows mobile:

    userAgent.contains('Windows.NT.5')
    

    I'm not sure if a more recent list needs applying