I have read dozens of comments about Google Places queries returning Request_Denied yet nothing seems to be informative for my situation. The app is IOS7 and Xcode 5.0.2.
I have an API key for IOS Applications. In the Google Developers Console the application bundle identifier is listed in the credentials page, and Places API is enabled.
Here’s the core of the code:
-(void)queryGooglePlaces: (NSString *)googleType {
NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%@&types=%@&sensor=false&key=%@", currentCenter.latitude, currentCenter.longitude, [NSString stringWithFormat:@"%i",currenDist], googleType, kGOOGLEAPIKEY];
NSLog(@"And the url string is: %@", url);//caveman debuging
NSURL *googleRequestURL = [NSURL URLWithString:url];
dispatch_async(kBgQueue, ^{
NSData *data = [NSData dataWithContentsOfURL:googleRequestURL];
[self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
});
}//queryGooglePlaces:googleType
-(void)fetchedData:(NSData *)responseData {
//this is to parse out the json data
NSError *error = nil; //create some error handling here
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
//I'm told the returned results from Google will be an array obtained from the NSDictionary object with the key "results"
NSArray *places = [json objectForKey:@"results"];
//display the data to the console for review
NSLog(@" Google data:\n%@", places);
}//fetchedData:responseData
The effect in the debug output shows that json status = Request Denied
key __NSCFString * @"status" 0x09a37d10 value __NSCFString * @"REQUEST_DENIED" 0x17961870
and here is the log for the url string, And the url string is: https://maps.googleapis.com/maps/api/place/search/json?location=37.787359,-122.408227&radius=996&types=cafe&sensor=false&key=
I have regenerated the API key with no effect.
ANY help would be appreciated!