0

Actually I can detect the iOS version but it is possible to detect a iPhone model 3G or 3GS inside iOS?

Thanks

Maxime
  • 3,167
  • 7
  • 26
  • 33
  • possible duplicate of [how do I detect whether I have iPhone 2G,3G,3GS](http://stackoverflow.com/questions/1543925/how-do-i-detect-whether-i-have-iphone-2g-3g-3gs) – Evan Mulawski Aug 17 '11 at 14:42
  • Check for the capabilities that you need (ie: video, phone, compass, gyros, etc) rather than check for specific models. – progrmr Aug 25 '11 at 22:56

2 Answers2

3

You need to check for device capabilities. The 3g does not support video recorder and the 3gs does not support front facing camera. Take a look to this question.

Community
  • 1
  • 1
Alex Terente
  • 12,006
  • 5
  • 51
  • 71
1

You can find the exact model string using this post (which I think is also a duplicate question):

#include <sys/types.h>
#include <sys/sysctl.h>

@implementation UIDevice (Hardware)

/*
 Platforms
 iPhone1,1 -> iPhone 1G
 iPhone1,2 -> iPhone 3G 
 iPod1,1   -> iPod touch 1G 
 iPod2,1   -> iPod touch 2G 
*/

-(NSString *) platform
{
  size_t size;
  sysctlbyname("hw.machine", NULL, &size, NULL, 0);
  char *machine = malloc(size);
  sysctlbyname("hw.machine", machine, &size, NULL, 0);
  NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
  free(machine);
 return platform;
}
Community
  • 1
  • 1
larsacus
  • 7,346
  • 3
  • 26
  • 23