I am trying to get a user agent of a window phone i am using this way to get it
private const string Html =
@"
<html>
<head>
<script language=""javascript"" type=""text/javascript"">
function notifyUA() {
window.external.notify(navigator.userAgent);
}
</script>
</head>`enter code here`
<body onload=""notifyUA();""></body>
</html>";
public static void GetUserAgent(Panel rootElement, Action<string> callback)
{
var browser = new Microsoft.Phone.Controls.WebBrowser();
browser.IsScriptEnabled = true;
browser.Visibility = Visibility.Collapsed;
browser.Loaded += (sender, args) => browser.NavigateToString(Html);
browser.ScriptNotify += (sender, args) =>
{
string userAgent = args.Value;
rootElement.Children.Remove(browser);
callback(userAgent);
};
rootElement.Children.Add(browser);
}
this is working fine in case of WP 8.0 but incorrect in case of WP 8.1
by code i am getting UA as
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 630)
But from whatsmyuseragent.com
Mozilla/5.0 (Windows Phone 8.1; ARM; Trident/7.0;Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 630) like Gechko please help me ...
Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 630)
for backwards compatibility, but the whatsmyuseragent.com is smart enough to figure out the correct version. Can you verify which user agent version is sent to the website, using Fiddler? – Erti-Chris Eelmaa