2

I am wondering in Phonegap/Cordova is there anyway to detect IOS version? Because i need to distinguish between IOS 8 and Prior as the push notification payload limit is different for 8Prior and 8.

Thanks

John
  • 983
  • 1
  • 13
  • 31
  • **There is no difference inside the payload between iOS 7 and iOS 8** - the **only difference** is **in** the **registration process** for the device token, not in the payload! Make clear where the diffs. are the next time. The only thing that is different is the size of 2048Byte now instead of 256byte prior iOS8 - make sure, that your Push-Messages are not bigger and thats all http://stackoverflow.com/a/25990240/3671726 – Sithys Jun 19 '15 at 08:11
  • You say in lots of answers 'I'll try it out' but there is not feedback from you for future readers. That's pretty selfish – Wrong Mar 15 '19 at 07:13

3 Answers3

3

According to cordova docs, you can use var string = device.version; to get the device version.

Example from 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>
turtle
  • 1,619
  • 1
  • 14
  • 30
1

Try something like this:

// 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;

From the documentation here: https://github.com/apache/cordova-plugin-device#quick-example-3

Hope that helps!

mez.pahlan
  • 1,053
  • 2
  • 11
  • 25
0

You can use window.cordova.platformId for platform name and use window.cordova.platformVersion to detect the platform version, no need to use any third-party plugins

Ata Iravani
  • 2,146
  • 7
  • 29
  • 40