Details
Description
Summary:
Currently, you can only fetch the OS version as a string via the Ti.Platform.version property. This is not convenient to use when you only want to call APIs on higher OS versions. For example, we've seen a lot of code that looks like the below.
if (OS_IOS && parseInt(Ti.Platform.version.split('.')[0]) >= 13) { |
// Do something on iOS 13 or higher... |
}
|
Feature Proposal:
Add the following properties to Ti.Platform...
- Ti.Platform.versionMajor // Returns an integer.
- Ti.Platform.versionMinor // Returns an integer.
Also add the following global constants.
(These will pair well with OS_ANDROID and OS_IOS.)
- OS_VERSION_MAJOR
- OS_VERSION_MINOR
This will make the above code example look simpler like this...
if (OS_IOS && (OS_VERSION_MAJOR >= 13)) { |
// Do something on iOS 13 or higher... |
}
|
Note:
On Android, we have a Ti.Platform.Android.API_LEVEL constant which is a single integer used to represent all Android OS versions. It's best to use this if you can, but note that no other platform has a similar concept... while all operating system support a <major>.<minor> version that we can use for parity.
https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels
Attachments
Issue Links
- is cloned into
-
TIMOB-28098 TiAPI: Add OS version patch integer constants
-
- Closed
-