1

I want to determine whether my Flex mobile app is running on a IOS device with IOS 7.

I need to find out because I want to lower the actionbar of the application if it is run on IOS 7 to provide room for the indicators (battery, wifi, etc.).

According to documentation the Flex Capabilities class does not provide me with an IOS version number.

The only option I can think of is to build a Native extension and query the version using IOS functions. But I do not really look forward to building that extension. Even less so because apparently you need a Mac with XCode to build the IOS part, and I don't own a Mac. A VM with OSX installed could be my last resort.

Maybe you know another option?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Dawied
  • 897
  • 10
  • 16

1 Answers1

2

Flex 4.12 actually introduced a way to fix this through CSS (4.12 introduced OS and OS version checks as well, which is awesome):

@media (application-dpi: 160) AND (os-platform:"IOS") AND (min-os-version: 7)
{
    Application {
         osStatusBarHeight: 20;
    }
}

But to answer your question, this function does the job:

public static function get iOSVersion():uint {
    var iosVersion:String = Capabilities.os.match( /([0-9]\.?){2,3}/ )[0];
    return Number( iosVersion.substr( 0, iosVersion.indexOf( "." ) ) );
}

I pulled that from my personal AS3 utility library. For sure, this will not work to get the Android version number and I am unsure if it will work for Mac or Windows. It will return the major version number only (minor versions are generally irrelevant). If you want to change that, just return iosVersion in the function instead of the second line.

Josh
  • 8,079
  • 3
  • 24
  • 49
  • Thanks! Now I face the task of migrating to Apache Flex. – Dawied Apr 06 '14 at 14:28
  • Ah, this works in Flex 4.6 as well, no need to migrate (yet). – Dawied Apr 06 '14 at 14:40
  • 1
    The top part was implemented in Flex 4.12 (`os-platform`, `min-os-version`, and `osStatusBarHeight` all were), so you would absolutely have to upgrade to use it (upgrading should be painless, honestly). The second part has been in AIR for as long as I can remember. You're just parsing the OS string, which on iOS includes the version number. No need for Flex at all. – Josh Apr 06 '14 at 16:18