Maxime
Maxime

Reputation: 3165

Detect iPhone 3G in iOS

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

Thanks

Upvotes: 0

Views: 1236

Answers (2)

larsacus
larsacus

Reputation: 7346

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;
}

Upvotes: 1

Alex Terente
Alex Terente

Reputation: 12036

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.

Upvotes: 3

Related Questions