0

I am using a WKWebview to display web page and have a UITextField where the user can enter the URL they wish to navigate to (in-app browser of sorts). As the user is typing, I would like to display a list of possibilities (i.e. popular sites). Are there any Apple (or 3rd party) APIs I could use to fetch a list of popular sites based on a substring?

Edit: I need to use a WKWebView as opposed to the new Safari View Controller because I want to be able to inject custom javascript (which is not allowed in the former)

David Tsenter
  • 125
  • 1
  • 1
  • 6

1 Answers1

1

Use this URL for auto complete

http://suggestqueries.google.com/complete/search?client=chrome&q=YOURQUERY

Like

search?client=chrome&q=apple

Use TableView For Showing the suggestions.

- (IBAction)act_search:(id)sender {
    if([_txt_search.text length] > 2)
    {

        Code Here ...

        [_tableview reloadData];


    }
    else
    {
        jsonarr = nil;
        [_tableview reloadData];
    }


}
Satish Babariya
  • 3,062
  • 1
  • 15
  • 29
  • This seems like an unofficial google api (no docs that I could find) and could be terminated at any time as per this article https://webmasters.googleblog.com/2015/07/update-on-autocomplete-api.html Do you know if there is a similar public API? – David Tsenter Apr 07 '17 at 17:19
  • I don't think any official documents are available right now but you can refer this like instead (if it helps). http://shreyaschand.com/blog/2013/01/03/google-autocomplete-api/ – Satish Babariya Apr 07 '17 at 17:50
  • Thanks! This is the best solution at the moment but will keep the question open in case anyone else has alternatives. If by tomorrow nothing happens then this will be the accepted answer :) – David Tsenter Apr 07 '17 at 17:53