Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How to id iphone device type

What's the best way to tell iPhone devices – 2G, 3G, 3GS and the 4 aparted? My goal is to query remote xml data by device type, so to return more or less data depend of device capability.

None of those gives me enough info…

alert(Titanium.Platform.name + Titanium.Platform.osname + Titanium.Platform.ostype + Titanium.Platform.version )

— asked June 25th 2010 by Daniel Lim
  • device
  • iphone
  • model
  • type
1 Comment
  • Hi - take a look at KitchenSink/Resources/examples/version.js. It should have all the info you are looking for …

    There are two functions, isIPhone3_2_Plus() and isiOS4Plus().
    var version = Titanium.Platform.version.split(".");

    where version[0] is the major and version[0] is the minor. I hope this helps.

    — commented December 23rd 2010 by David Gretlein

4 Answers

  • not the whole answer you want to hear…. but just fyi…

    if (Titanium.Platform.name == 'iPhone OS'){
    Ti.API.info('——– entering iPHONE ———-');
    };

    if (Ti.Platform.name == "android"){
    Ti.API.info('——– entering ANDROID ———-');

    };

    — answered June 25th 2010 by vincent youmans
    permalink
    0 Comments
  • Thanks,

    Yeah, i know and i've been using this to tell iPad apart, those sample in Kitchen sink doesn't work for me….

    Titanium.Platform.model.indexOf('iPad')!=-1

    — answered June 25th 2010 by Daniel Lim
    permalink
    0 Comments
  • I am getting a fatal error on Continuous 1.5.0 on ANDROID when I call this:
    Ti.Platform.name

    — answered December 9th 2010 by vincent youmans
    permalink
    2 Comments
    • In this I am getting
      = 'undefined' is not an object (evaluating 'win.add') at app.js

      — commented July 10th 2012 by Suchismita Pavan
    • if you know the width of the device in which app is installed, then you can put condition on width as below.

      if(Titanium.Platform.displayCaps.platformWidth == '320') {
          //Iphone Configurations
      }
      
      if(Titanium.Platform.displayCaps.platformWidth == '480') {
          //Android Configurations
      }
      
      if(Titanium.Platform.displayCaps.platformWidth == '768') {
          //Ipad Configurations
      }
      

      — commented July 28th 2012 by Abdus Sattar
  • if you know the width of the device in which app is installed, then you can put condition on width as below.

    if(Titanium.Platform.displayCaps.platformWidth == '320') {
        //Iphone Configurations
    }
    
    if(Titanium.Platform.displayCaps.platformWidth == '480') {
        //Android Configurations
    }
    
    if(Titanium.Platform.displayCaps.platformWidth == '768') {
        //Ipad Configurations
    }
    
    — answered July 28th 2012 by Abdus Sattar
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.