device.getInfo("model") should return "iPad3" or "iPadRetina"

device.getInfo(“model”) lets you tell the difference between “iPhone” and “iPhone4”

Similarly, it should tell you the difference between “iPad” and “iPadRetina”.

[import]uid: 122310 topic_id: 27374 reply_id: 327374[/import]

I found some code here and tweaked it to my needs that can help determine a more exact iOS device you’re using. Here’s my version of the function:

[code]local function iOStype( request )
local deviceName, retina, isIOSdevice
local pixelWidth = math.floor((-display.screenOriginX * 1.975 + display.contentWidth) / display.contentScaleX )
local pixelHeight = math.floor((-display.screenOriginY * 2 + display.contentHeight) / display.contentScaleY )
local deviceWidth = ( display.contentWidth - (display.screenOriginX * 2) ) / display.contentScaleX
local scaleFactor = math.floor( deviceWidth / display.contentWidth )

if pixelWidth == 480 and pixelHeight == 320 then deviceName = “iPhone/iPod touch”; isIOSdevice = true
elseif pixelWidth == 960 and pixelHeight == 640 then deviceName = “iPhone 4/iPod touch 4G”; isIOSdevice = true
elseif pixelWidth == 1024 and pixelHeight == 768 then deviceName = “iPad/iPad 2”; isIOSdevice = true
elseif pixelWidth == 2048 and pixelHeight == 1536 then deviceName = “new iPad”; isIOSdevice = true
else
deviceName = “non-iOS device”; isIOSdevice = false
end

if request == “device” then return deviceName
elseif request == “isIOS” then return isIOSdevice
elseif request == “resolution” then return pixelWidth, pixelHeight
elseif request == “retina” then return scaleFactor
else
return deviceName, isIOSdevice, pixelWidth, pixelHeight, scaleFactor
end
end[/code]
And you can use it like this:local dev,iS,pW,pH,scale = iOStype() print("Device type: " .. dev .. "\nActual resolution: " .. pW .. "x" .. pH .. "\nRetina scaling factor: " .. scale )
Or something like this:

if iOStype( "isIOS") then print( "Cool, I'm a(n) " .. iOStype( "device" ) .. "!" ) else print( "Eh, I'm not an iOS device." ) end
And this:

local iOSdevice = iOStype( "device" ) if string.match( iOSdevice, "iPad" ) ~= nil then print ( "Yay, I'm an iOS tablet!" ) elseif string.match( iOSdevice, "iPhone" ) ~= nil then print ( "Yay, I'm an iOS smartphone or handheld!" ) else print ( "I'm not an iOS device." ) end [import]uid: 6084 topic_id: 27374 reply_id: 111227[/import]

Thank you for the excellent tip, @BeyondtheTech!

I also found that

[lua]system.getInfo(“architectureInfo”)[/lua]

will get you the “iPad3,1” or “iPhone2,1” type identifiers as listed here:

http://www.everyi.com/by-identifier/ipod-iphone-ipad-specs-by-model-identifier.html [import]uid: 122310 topic_id: 27374 reply_id: 111350[/import]

Wow, I totally forgot about that property. I’ve gone ahead and tweaked the above code and put a nice module together in the Code Sharing section:

http://developer.anscamobile.com/code/iosinfo-definitive-way-determine-type-ios-device-your-app-running

Thanks again! [import]uid: 6084 topic_id: 27374 reply_id: 111403[/import]