Detect iPhone 4 devices
I have improved all the graphics in my apps but I want to be able to detect wether the user has an iPhone 4 or not. The higher quality tab bar icons don't look so good on older devices. I'd like to just detect the higher res display.
I thought about using this:
Titanium.Platform.displayCaps.dpi
In the simulator, the iPhone 4 returns 160 so I know it's not working there. Any ideas of how to detect an iPhone 4?
4 Answers
-
Accepted Answer
Andrew,
That doesn't work. I tried to do the same thing for one of my apps, but when you use Titanium.Platform.model it doesn't come back as iPhone 4 when on a iPhone 4, it just says iPhone for me.
-
by "in the simulator the iphone returns 160" you mean even after choosing the iphone4 in the simulator menue under hardware/devices?
what about the screen-dimension: do you get the real pixels for width and height? if so using Titanium.Platform.osname combined with a screensize of 960px (i guess) would mean your app is running on the iphone4
-
You can find an example here http://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/version.js
-
This what I found to work for me. I don't have an iPhone 4 to test it 100%.
if (Titanium.Platform.model=='iPhone 4' || Titanium.Platform.model=='Simulator') { var tab2 = Titanium.UI.createTab({ icon:'calc_icon@2x.png', title:'Fog', window:win2 }) } else { var tab2 = Titanium.UI.createTab({ icon:'calc_icon.png', title:'Fog', window:win2 }) };