tags:

views:

281

answers:

3

I want to allow only users with a 3G phone to use a particular GPS function. How do I run a check on the device before allowing that feature to be used?

+3  A: 

The following code with allow you to determine the exact device that is in use but I would first consider the fact that a 3G device may not actually be able to obtain a GPS lock as the process of doing so is quite slow and requires a more or less clear view of the sky.

For an iPhone 3G the result of this method will be iPhone1,2

- (NSString *)deviceModel
{
    NSString *deviceModel = nil;
    char buffer[32];
    size_t length = sizeof(buffer);
    if (sysctlbyname("hw.machine", &buffer, &length, NULL, 0) == 0) {
     deviceModel = [[NSString alloc] initWithCString:buffer encoding:NSASCIIStringEncoding];
    }
    return [deviceModel autorelease];
}
wisequark
A: 

is this method approved by apple?

A: 

Why would you stop 1g phone users from using location services? If you are near mapped WiFi you can get decent location results even without a GPS on the device.

Instead you should base your choice of what to do around the current location accuracy, if that is a reason why you seek to disable anything.

Kendall Helmstetter Gelner