0

The operation couldn’t be completed. An internal error occurred in the Places API library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/support).

I am getting this error. I was able to work for some hours . Nothing changed in code. After some time i am getting the above error for every request

Some code in iOS i used

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSString *text = [textField text];
    text = [text stringByReplacingCharactersInRange:range withString:string];
    if (text.length>0) {
        footerView.hidden = NO;
        [footerView startAnimating];
    }else {
        [self removeDropDown];
        return YES;
    }
    [_fetcher sourceTextHasChanged:text];
    return YES;
}

Delegate methods

- (void)didAutocompleteWithPredictions:(NSArray *)predictions {
    resultsArray = [[NSMutableArray alloc]init];
    NSMutableArray *titlesArray = [[NSMutableArray alloc]init];
    for (GMSAutocompletePrediction *prediction in predictions) {
        [titlesArray addObject:[prediction.attributedPrimaryText string]];
        [resultsArray addObject:prediction];
    }

    if (self.searchTextField.text.length>0) {
        if (dropDown == nil) {
            dropDown = [[PTDropDownView alloc] showDropDown:self.searchParentView withheight:autoCompleteViewMaxHeight withItems:titlesArray animationDirection:DirectionDown];
            dropDown.delegate = self;
        } else {
            dropDown.itemsArray = titlesArray;
            [dropDown.tableView reloadData];
        }
        dropDown.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
        [self adjustDropDownFrame];

        [footerView stopAnimating];
    }

    NSLog(@"fetched count = %d",resultsArray.count);

}

- (void)didFailAutocompleteWithError:(NSError *)error {

        NSLog(@"%@",[NSString stringWithFormat:@"%@", error.localizedDescription]);
    [self removeDropDown];
}
MuraliMohan
  • 1,063
  • 1
  • 11
  • 30

3 Answers3

1

we need to provide API_Key for GSMPlacesClient like GMSPlacesClient.provideAPIKey("Your_APIKey") just like we go it for GMSServices

dRAGONAIR
  • 1,181
  • 6
  • 8
0

I was able to resolve the error by ensuring that an empty query was not being sent. Note that I am not using the GMSAutoCompleteFetcher() wrapper and instead using a shared GMSPlacesClient to fetch predictions.

Swift 2:

    func autocompleteQuery(withQuery query: String) {
    if !query.isEmpty {
        placesClient.autocompleteQuery(query, bounds: self.bounds, filter: .None) { results, error in
            guard error == nil else {
                print("Autocomplete error \(error)")
                return
            }
            self.predictions = results!
            dispatch_async(dispatch_get_main_queue()) { self.autocompleteResultsTableView.reloadData() }
        }
    }
}
mayankk2308
  • 901
  • 1
  • 8
  • 14
0

After some days i come to know that it will give the results for certain number of searches per a day. I got the above error in one day. In next day without code change that is working.

MuraliMohan
  • 1,063
  • 1
  • 11
  • 30
  • This seems to be the right solution though it's not really a means to an end. I'm currently going through the exact same issue with Google Places API and nothing has changed in my codebase. I'm wondering what the internal error could be and if it's anything pertaining to my Xcode version or just my Xcode in general. –  Mar 03 '17 at 00:00