Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28061

TiAPI: Add OS version major/minor integer constants

    Details

    • Story Points:
      5

      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

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Christopher Williams
                Tester:
                Samir Mohammed
              • Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration