Google Place Search API and iOS

If you're trying to use the Google Place Search API with an iOS public API key you may very well see the following message:

This IP, site or mobile application is not authorized to use this API key.

As of the time this post was written, "The Places API currently only works with browser and server keys, not iOS and Android keys." and the latest information I've found indicates that "The preferred work around is to create a server hosted component for your application that communicates with Google's Places API services to retrieve the information you need".

If that sounds like a huge PITA, you can try using a browser key and adding a referrer to your NSURLRequest.

 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString]];
 [request setValue:@"" forHTTPHeaderField: @"Referer"]; // I wish that was a typo...

As long at that referrer domain matches a pattern (*) you've allowed under that API key things should hopefully work.

This is why I have more and more gray beard hairs all the time.

"Google Place Search API and iOS" was originally published on 12 Aug 2014.