Corona SDK and other Game Development Tutorials

Device Detection

As you know, Corona SDK is great cross-platform tool that allows developers to build once and publish everywhere. And recently, I was developing an app with Corona SDK that needed to operate differently based on the device the app was on. Basically, I needed to detect whether or not the app was being run on iOS or Android and while I could have kept two separate code bases to make this happen, I only wanted to keep one.

This led me to look up how to detect devices and Corona provides a real easy way to detect what device the user is on using system.getInfo. By calling system.getInfo, you can find out what model of phone the app is on, the platform, and even the environment (simulator or device)! Let’s take a look how.


Calling system.getInfo(“model”)) will show us the device model that the app is on. Below are the some of the possible results.

  • “iPhone”
  • “iPad”
  • “iPhone Simulator”
  • “iPad Simulator”
  • “Nexus One”
  • “Droid”
  • “Galaxy Tab”

Of course there are more results than listed here such as the Kindle Fire and Nook, but you get the idea. I was able to use this API in an if-then statement to detect the device. Here’s a peek at the code I used.

if(system.getInfo("model") == "iPad" or system.getInfo("model") == "iPhone") then
  print('Do iPhone and iPad things.')
  print('Do something else.')

As you’ve just learned, Corona makes it very, very easy to detect the model that the app is on. This is handy when you want to make cross-platform games, but only want to use some features for iOS and other features for Android. If you’d like to learn more about this very helpful API, visit for more information! Thanks for reading!

Leave a Reply