×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2012.821 | Released: 23 May 2012, 2:01am | What's New | Download Now

system.getInfo()

Description:

Returns information about the system on which the application is running.

Syntax:

1
system.getInfo( parm )

Example:

print( system.getInfo( "deviceID" ) )  -- display the deviceID

Parameters:

parm

The first argument param is a string that determines what is returned.

Valid values for param:

"name" returns the human readable model name. On iPhone, this would be the name of the phone as it appears in iTunes, e.g. "Steve's iPhone".

"model" returns the device model (as specified by the manufacturer). These include:

  • "iPhone"
  • "iPad"
  • "iPhone Simulator"
  • "iPad Simulator"
  • "Nexus One"
  • "Droid"
  • "Galaxy Tab"

Note: The above is a list of all the iOS models and the Android devices used in the Corona Simulator. Most Android devices return a model number instead of a model name.

"deviceID" returns the unique id of the device, e.g. IMEI or similar number.

"environment" returns the environment that the app is running in. These include:

  • "simulator" the Corona Simulator
  • "device" iOS, Android device and Xcode Simulator

"platformName" returns the platform name (the OS name), i.e. one of the following:

  • "Mac OS X" (Corona Simulator on Mac)
  • "Win" (Corona Simulator on Windows)
  • "iPhone OS" (all iOS devices and Xcode Simulator)
  • "Android" (all Android devices)

"platformVersion" returns a string representation of the platform version. This is sometimes, but not always, a number -- for example a Droid X is currently returning "2.1-update1".

"version" This is deprecated. Use "build" instead to distinguish between different Corona build versions.

"build" returns the Corona build string as it appears in the About box of the Corona Simulator.

"textureMemoryUsed" returns the texture memory usage (in bytes). Texture memory (for graphics/images) tends to be the most sharply limited resource in mobile development, since it runs out before normal memory.

"maxTextureSize" returns the maximum texture width or height supported by the device. (Available starting from Build 2011.310)

"architectureInfo" returns a string describing the underlying CPU architecture of the device you are running on. This API is mostly for internal debugging but may have uses. Strings may be subject to changes in the future depending on the changing landscape of devices and CPUs. (Available starting from Build 2011.326).

Android on ARM devices will return "ARM" (typically for ARMv6) or "ARM Neon" (ARMv7). iOS will return values such as: "iPhone1,1", "iPhone1,2", where mappings are:

  • "iPhone1,1" = iPhone 1G
  • "iPhone1,2" = iPhone 3G
  • "iPhone2,1" = iPhone 3GS
  • "iPod1,1" = iPod touch 1G
  • "iPod2,1" = iPod touch 2G

Mac may return i386, x86_64, ppc, or ppc64. (Currently only i386 is available.)
Windows is currently unsupported.

Returns:

String of parameter requested.

Remarks:

"maxTextureSize" available in Build 2011.310
"architectureInfo" available in Build 2011.326

Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 2.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 2.0
  • Android:
    Corona SDK 2.0

Replies

BeyondtheTech
User offline. Last seen 1 hour 35 min ago. Offline
Joined: 14 Apr 2010

I don't have an iPad, would the platformName return as "iPad" or "iPhone OS" ?

snarla's picture
snarla
User offline. Last seen 16 weeks 1 day ago. Offline
Alumni
Joined: 25 May 2010

iPad = iOS = "iPhone OS"
Hopefully the documentation is clearer now.

BeyondtheTech
User offline. Last seen 1 hour 35 min ago. Offline
Joined: 14 Apr 2010

"architectureInfo" is going to help me big-time. A big thank you!

finefin
User offline. Last seen 45 weeks 6 days ago. Offline
Joined: 14 Jun 2011

actually, when running on iPod touch the parameter "model" returns "iPod touch".
remember that when you're setting up your isiPhone-trigger:

1
2
3
4
5
6
7
8
9
-- check device
isIPhone = false         
if(system.getInfo("model") == "iPhone") or (system.getInfo("model") == "iPod touch") then
    isIPhone = true
end
 
if isIPhone == true then
   print("iPhone or iPod touch, yaay!")
end

brian0405
User offline. Last seen 3 days 13 hours ago. Offline
Joined: 21 Jan 2011

Finefin - great code! Thanks

aleeri
User offline. Last seen 1 week 4 hours ago. Offline
Joined: 25 Nov 2010

>>"deviceID" returns the unique id of the device, e.g. IMEI or similar number.

so the little android tells me :

357342043390887

which is the IMEI

but all the ios devices tell me something like:

c35b8a34b69b972806d57fb2f0c2228c938c069a

okay now. what is that? i mean it looks like a hash to me...
so what does "or simmilar" exactly mean?

Tom
User offline. Last seen 11 hours 3 min ago. Offline
Staff
Joined: 13 Jul 2010

It means what ever the device manufacturer wants it to mean. We just report the deviceID returned by the device.

d3mac123
User offline. Last seen 4 weeks 2 days ago. Offline
Joined: 12 Feb 2010

Which string it will return for the Amazon Fire?

Tom
User offline. Last seen 11 hours 3 min ago. Offline
Staff
Joined: 13 Jul 2010

Amazon Fire returns "Amazon Fire" for model.

dyuman.bhatt
User offline. Last seen 5 weeks 4 days ago. Offline
Joined: 11 Jul 2011

Is it possible for us to get this information?

Country Code
Language Code
Carrier Name
Carrier ISO country code
Carrier Mobile Country Code
Carrier Mobile Network

This would be really helpful if we could have this for internal analytic.

All the other stuff is helpful but I really would like more.

akao's picture
akao
User offline. Last seen 1 week 1 day ago. Offline
Joined: 25 Feb 2011

What information would a NOOK return for "model"? Thx.

Blue Spruce Games's picture
Blue Spruce Games
User offline. Last seen 2 days 18 hours ago. Offline
Joined: 14 Feb 2011

How can we distinguish between iPhones with retina display and older phones without it? I want to load a movieclip with high-def graphics for the retina displays, but I don't see a way to check it the device has retina.

@RSCdev's picture
@RSCdev
User offline. Last seen 5 hours 19 min ago. Offline
Joined: 6 Sep 2011

@finefin - Thank You!

Your post was the unique place I found some info about what the API "model" returns when it`s an iPod (that returns "iPod touch").

Happy 2012!

Cheers,
Rodrigo.

treitel
User offline. Last seen 5 weeks 5 days ago. Offline
Joined: 12 Oct 2011

you can use this to get informations about "older" and newer retina devices.

1
2
3
4
5
6
7
Device.getSuffix = function()
        if system.getInfo('maxTextureSize') > 1024 then
                return "@2x";
        else
                return "";
        end;
end;

Tom
User offline. Last seen 11 hours 3 min ago. Offline
Staff
Joined: 13 Jul 2010

@treitel, not all devices > 1024 maxTextureSize are Retina devices. The iPhone 3G and iPad return 2048 and they don't have retina displays. The iPhone 3 returned 1024.

sunmils
User offline. Last seen 1 week 3 days ago. Offline
Joined: 18 Apr 2011

How can I get the device name (UUID) on iphones/ipads? It's the first entry of Settings\General\Information.

y.sravankumar's picture
y.sravankumar
User offline. Last seen 23 hours 37 min ago. Offline
Joined: 13 Oct 2011

what this function will return for "platformName" if it is amazon kindlefire and for Nook??

rxmarccall's picture
rxmarccall
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 18 Jan 2011

I too would like to know what the platformName for Nook is, Tom above he said that kindle fire is "Amazon Fire"

daniel_natacion
User offline. Last seen 10 weeks 22 hours ago. Offline
Joined: 11 May 2011

Hi! How do know if I'm in any TABLET?

Tom
User offline. Last seen 11 hours 3 min ago. Offline
Staff
Joined: 13 Jul 2010

platformName for the Nook is "Android." I've seen the following model names returned for Nook:

BNTV250 for Nook Tablet
BNTV200 for Nook Color

Be aware that the manufacturer creates the model string and subject to change.

There is no full-proof way to tell if the device is a tablet or not. You can do a check of the model names and look at the display.width and display.height along with the scale factor, to make a guess about the device type.

james03's picture
james03
User offline. Last seen 5 days 12 hours ago. Offline
Joined: 14 May 2011

I think this is actually incorrect - just took possession of our Kindle Fire test device and system.getInfo("model") returns "Kindle Fire"

DavidBFox's picture
DavidBFox
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 10 Oct 2010

How can we tell if the device is a new iPad (retina)? And should the simulator return special values to help us determine this? In the newest build (2012.772) it returns 2048 for texture memory even when we're on the iPad Retina (is that correct)?

Tom
User offline. Last seen 11 hours 3 min ago. Offline
Staff
Joined: 13 Jul 2010

@DavidBFox,

The iPad Retina simulator returns "iPad" because that is what the real device returns. Historically, Apple doesn't want you to know what device you're running on so it doesn't make this information easy to get. You can tell if you are on certain device by either looking at the display.contentWidth and display.contentHeigh (if dynamic scaling is off) or the display.contentScaleX and display.contentScaleY.

The simulator does not simulate the texture memory size used by the device. It returns the value for the device you're simulating on.

DavidBFox's picture
DavidBFox
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 10 Oct 2010

Thanks Tom! I found the display.contentScaleX/Y worked well. But even better, after switching from the older display.newRetinaText() to the new display.newText() actually fixed my problem, so I didn't need to know which iPad it was running on.

akao's picture
akao
User offline. Last seen 1 week 1 day ago. Offline
Joined: 25 Feb 2011

Now that UDID is deprecated in iOS5, what will "deviceID" return? Will it still be a unique ID per device?

Thx!

jwwtaker
User offline. Last seen 8 hours 57 min ago. Offline
Joined: 28 Apr 2010

i'd also like to know the UDID question on iOS since deprecation. has it been changed yet in Corona since the new apple requirement?