5

On Apple's built-in Voicemail app, when it finds a phone number it does not recognize in your address book, it displays an approximate location under the number, presumably based on the phone number. How did they do that?? I'd guess there's a large database of area codes and exchange numbers on the phone, each mapping to a city or region name. Does anyone know if this mapping is accessible to apps via a public API?

There's lots of boilerplate code out there for mapping ZIP code to city, but I don't see much that does the same with area code / exchange. Any ideas?

Ryan
  • 221
  • 1
  • 14
  • A similar question was asked one day after this one: http://stackoverflow.com/questions/9284212/how-to-locate-any-mobile-number-using-iphone-application/18930785#18930785 – newenglander Sep 21 '13 at 09:00

3 Answers3

2

I've created a plist file that has the area codes and locations in it: areacodes.plist. To use it follow these steps:

If you just won't to use the plist file:

1. Add the plist file to your project.

2. Load the file:

NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"areacodes" ofType:@"plist"];
NSDictionary *areaCodeDict = [[NSDictionary alloc] initWithContentsOfFile:plistPath];

3. Use the dictionary you've loaded. The keys are the area codes, the values are the locations:

NSString *areaCode = @"801";
NSString *location = [self.areaCodeConversion objectForKey:areaCode];
NSLog(@"%@",location); // prints utah

To use the included class:

1. Add the downloaded folder to your project.

2. Use the included class to access the plist information:

#import "AreaCodes.h"
...
AreaCodes *areaCodes = [[AreaCodes alloc] init];
NSString *location = [areaCodes getLocationForCode:@"801"];
NSLog(@"%@",location);
// prints "Utah"
Jbryson
  • 2,805
  • 1
  • 29
  • 51
1

They would have probably bought a commercial product from a company such as Telcordia (trainfo.com). I work for GreatData.com and we maintain the area codes and prefixes (also called, 'NPA/NXX'), along with the primary city (rate center) state, time zone, operating company, etc., but we don't have latitude / longitude. (Telcordia would).

I don't believe you could find the data that you're looking for in a free product. We've spent tons of time manually verifying our data.

user1473461
  • 371
  • 2
  • 2
1

There are a number of web sites that will tell you the city or cities for a given area code. Verizon has one, and other sites like http://www.allareacodes.com/ and http://www.411.com/area_zip_codes do about the same thing. You can probably find the same information in the front of your local telephone directory, too.

Since there are fewer than 1000 possible area codes, I'd look for an area code list that you can include in your program. That way, this aspect of your app will work whether a network connection is available or not.

Caleb
  • 120,112
  • 19
  • 171
  • 259