-
-
Save henriqueutsch/607128bacff2c9c9f02a2ba020eb2745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mobile_device | |
# user_agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36' | |
user_agent = request.env['HTTP_USER_AGENT'] | |
client = DeviceDetector.new(user_agent) | |
client.name # => 'Chrome' | |
client.full_version # => '30.0.1599.69' | |
client.os_name # => 'Windows' | |
client.os_full_version # => '8' | |
# For many devices, you can also query the device name (usually the model name) | |
client.device_name # => 'iPhone 5' | |
# Device types can be one of the following: desktop, smartphone, tablet, console, | |
# portable media player, tv, car browser, camera | |
return client.device_type # => 'smartphone' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment