John
John

Reputation: 1003

PhoneGap How to detect IOS version?

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

Upvotes: 2

Views: 4987

Answers (3)

Ata Iravani
Ata Iravani

Reputation: 2206

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

Upvotes: 0

turtle
turtle

Reputation: 1619

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>

Upvotes: 3

mez.pahlan
mez.pahlan

Reputation: 1093

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!

Upvotes: 1

Related Questions