system.getInfo("model") == "iPhone4" works on simulator but not on device

I am building a universal app. I ran it in the simulator and have put in specific code to scale the app in my code. In the simulator
system.getinfo(“model”) – returns “iPhone4” for the iPhone4 device simulator
On an actual iPhone4 device system.getinfo(“model”) – returns “iPhone”. As a workaround I have put an extra option in my if statement that checks if it is “iPhone” and display.contentWidth == 640 then I assume the device is an iPhone 4. This works.
[import]uid: 21633 topic_id: 5721 reply_id: 305721[/import]

Nice, thanks!

[lua]-- iPhone 4 Specific

isiPhone4 = false

if(system.getInfo(“model”) == “iPhone” and display.contentWidth == 640)then
isiPhone4 = true
end[/lua] [import]uid: 10976 topic_id: 5721 reply_id: 21105[/import]

Something else others should be aware of, the Simulator WINDOW menu for “View As” lists “NexusOne” with no space, but the API call returns “Nexus One”. “Galaxy Tab” is consistent though. Just a heads-up when using system.getInfo(“model”) [import]uid: 74844 topic_id: 5721 reply_id: 49133[/import]

That looks like a bug on the Mac Simulator. iPhone4 skin should return the same string as on an actual device, “iPhone”. I’ll file a bug to have it fixed. Thanks.
[import]uid: 7559 topic_id: 5721 reply_id: 49793[/import]

I’m a little confused about what system.getInfo( “model” ) returns after reading this post. I’d very much appreciate it if someone can confirm that the following is true:

Returns “iPhone” from any and all generation of iPod Touch and iPhone
Returns “iPad” from any and all generation of iPad

I’m about to code it as follows, but I need to know whether or not I should instead check individually for “iPhone”, “iPhone4”, “iPhone4S”, “iPad” and “iPad2”:

[lua]local deviceModel = system.getInfo( “model” );
if (deviceModel == “iPad”) then
– do this for any kinds of iPad
else
– do this for any kinds of iPhone
end[/lua] [import]uid: 67217 topic_id: 5721 reply_id: 59793[/import]

Naomi, you have to note that above the check of whether it is an iPhone will work for what I believe you’re doing; but the additional check for resolution confirms the model. Of course, this doesn’t / can’t account for future models where unknown resolutions might increase/change.

What you have coded “appears” to be good enough for what you’re attempting to do. Personally, I don’t know if I would assume the “else” is an iPhone myself…but that’s just me. [import]uid: 74844 topic_id: 5721 reply_id: 59794[/import]

Thank you, Jerome! Yes, I thought it very clever to use display.contentWidth to determine the generation of iPhone / iPod Touch.

The reason I’m using “else” to determine it’s iPhone (if not iPad) is because my plan is to build for App Store. I’d need to port my game to non iOS device after iOS version is done. I just can’t even imagine building my game from ground up to support both iOS and non-iOS devices. Too overwhelming to work it out for me at the moment.

Thanks again! [import]uid: 67217 topic_id: 5721 reply_id: 59798[/import]

Hmmm… I could also do:
[lua]local deviceModel = system.getInfo( “model” );
if (deviceModel == “iPad”) then
– do this for any kinds of iPad
elseif (deviceModel == “iPhone”) then
– do this for any kinds of iPhone
end[/lua]

I wonder which is better, and I wonder if there is a compelling reason to narrow it down this way. [import]uid: 67217 topic_id: 5721 reply_id: 59799[/import]

Naomi, I don’t even mean that “else” could be Android device… I mean what if Apple brings out another device? [import]uid: 74844 topic_id: 5721 reply_id: 59801[/import]

Ah, got it, Jerome. I have to think about what it means to limiting it to “iPad” and “iPhone” only though. Maybe it’s okay for some new device to run iPhone version. I mean, if someone with spanking new device wants to run my game in some unforeseeable future, hey, that can only be a good thing?

Edit: The thought prompted me to swap the position between “iPad” and “iPhone” – so, if it’s “iPhone”, do this, else do this for “iPad”. Cheers! [import]uid: 67217 topic_id: 5721 reply_id: 59805[/import]

I bet you’ll be fine then… ciao bella. :wink: [import]uid: 74844 topic_id: 5721 reply_id: 59806[/import]