我想知道Phonegap / Cordova还有检测IOS版本吗?因为我需要区分IOS 8和Prior,因为8Prior和8的推送通知有效负载限制是不同的。
由于
答案 0 :(得分:3)
根据cordova docs,您可以使用var string = device.version;
获取设备版本。
来自cordova docs的示例:
<!DOCTYPE html>
<html>
<head>
<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
function onDeviceReady() {
var element = document.getElementById('deviceProperties');
element.innerHTML = 'Device Model: ' + device.model + '<br />' +
'Device Cordova: ' + device.cordova + '<br />' +
'Device Platform: ' + device.platform + '<br />' +
'Device UUID: ' + device.uuid + '<br />' +
'Device Version: ' + device.version + '<br />';
}
</script>
</head>
<body>
<p id="deviceProperties">Loading device properties...</p>
</body>
</html>
答案 1 :(得分:1)
尝试这样的事情:
// Android: Froyo OS would return "2.2"
// Eclair OS would return "2.1", "2.0.1", or "2.0"
// Version can also return update level "2.1-update1"
//
// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600"
//
// iPhone: iOS 3.2 returns "3.2"
//
// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720
// Tizen: returns "TIZEN_20120425_2"
var deviceVersion = device.version;
从此处的文档:https://github.com/apache/cordova-plugin-device#quick-example-3
希望有所帮助!
答案 2 :(得分:0)
您可以使用window.cordova.platformId
作为平台名称,使用window.cordova.platformVersion
检测平台版本,无需使用任何第三方插件