Skip to main content
Feb 27, 2012 11:07 AM UTC
Answered

How do I get the platform on which my application is executed?

I need to determine on which platform (iOS or Android) my application is currently executed. Is there a way to do this? Until now I just found the Capabilities.os property which is I think for exactly this case. The problem with that property is, that it only return the different Windows version, or if the platform is a Mac or Linux or iPhone OS (is that iOS? I don't know...).

Are there any ideas how I could solve this?

This topic is closed to new replies. Start a new post to keep the conversation going.
Colin Holgate
Colin HolgateCorrect answer
Inspiring
Feb 27, 2012 1:16 PM UTC

Code that I've seen online suggests that "ios" is in the version, so doing this ought to work:

if (Capabilities.version.indexOf('IOS') < 0) {

4 replies

Participating Frequently
Feb 28, 2012 5:36 PM UTC

Also, you can check the Capabilities.manufacturer flag, which contains Android Linux, Apple iOS etc.

Translate
Feb 28, 2012 8:59 AM UTC

Thanks guys,

the solution of Colin Holgate works for me, although it should be

if (Capabilities.version.indexOf('IOS') >= 0) 

if i want to check if my application runs on iOS. If I want to check for Android I use, of course, AND instead of IOS.

Translate
Colin Holgate
Colin HolgateCorrect answer
Inspiring
Feb 27, 2012 1:16 PM UTC

Code that I've seen online suggests that "ios" is in the version, so doing this ought to work:

if (Capabilities.version.indexOf('IOS') < 0) {

Translate
Inspiring
Feb 27, 2012 6:48 PM UTC

I believe the code you have listed would be executed if the platform is NOT iOS.

I would suggest using the following and comparing to "AND", "IOS", "WIN", "LIN", and "MAC".

flash.system.Capabilities.version.substr(0,3).toUpperCase();

Translate