Reputation: 9287
I'm using this piece of code that is working correctly to detect iOS devices when browsing through the Safari browser:
def mobile_user_agent?
@mobile_user_agent ||= ( request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"] [/(Mobile\/.+Safari)/] )
end
But it doesn't detect a user coming to the site through an App's browser on the device. Mainly Twitter.
I believe this is the UA for a twitter user, so how do you accomodate for this (and other Apps as well?)
"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405"
Upvotes: 0
Views: 2734
Reputation: 1543
What i would do is change the regex to something like
/(Mobile\/.+Safari)|(AppleWebKit\/.+Mobile)/
Upvotes: 1