Reputation: 115
I'm working on a snippet for check the Firefox OS version used.
Now i'm using the gecko version in the user agent string (is different in every version of Firefox OS) but it's not a professional solution often is simple.
The gist: https://gist.github.com/Mte90/11087561
Any suggestion?
The gist is updated with the better solution for check the Firefox OS version
Upvotes: 1
Views: 386
Reputation: 1081
Not very nice way to do this but you could parse the user agent
function convertVersionNumber(ver) {
var hashVersion = {
'18.0': '1.0.1',
'18.1': '1.1',
'26.0': '1.2',
'28.0': '1.3',
'30.0': '1.4',
'32.0': '1.5'
}
var rver = ver;
var sStr = ver.substring(0, 4);
if (hashVersion[sStr]) {
rver = hashVersion[sStr];
}
return (rver);
} function getVersion() {
if (navigator.userAgent.match(/(mobile|tablet)/i)) {
var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/));
if (ffVersionArray.length === 2) {
return (convertVersionNumber(ffVersionArray[1]));
}
}
return (null);
}
Upvotes: 2
Reputation: 13
In /gaia/profile/settings.json
can you read the version?
Or use the settings api to read and compare:
deviceinfo.platform_version
Upvotes: 0
Reputation: 559
This is the only way I know to detect the version of Firefox OS right now. If it's also to see if a feature exists, I would, again, use feature detection instead of version detection.
if (navigator.connection) //Network Information API
if (navigator.battery) // Battery Status API
If these if return true, it's because those features are available on the version the user run your application on.
Upvotes: 2