Issue
Trying to recognise Android Native Browser using only its user agent with regular expression in Javascript.
Solution
This is what I came up with, its pretty long and I wonder if it can be shortened:
/.*(Linux;.*AppleWebKit.*Version\/\d+\.\d+.*Mobile).*/gi
Explanation and remarks:
- Does not detect any of the mentioned here: Safari, Chrome, Different Mobile.
Does detect 19 out of 20 mentioned here: Android Native, the one that is not getting detected does not comply with googles instructions (Google Developer)
If you’re attempting to differentiate between the WebView and Chrome for Android, you should look for the presence of the Version/X.X string in the WebView user-agent string.
Tried it without using 'Linux' but got false positive on safari browsers.
Answered By - Technotronic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.