Trending Searches

Get Trendings

To get trending searches, call the getTrendingSearches method on the ContextualSearchRuntime. This method takes a single GetTrendingSearchesOptions where you can specify the maximum number of trendings returned.

The returned SearchSuggestions object does not contain any accessible properties. It contains all of the necessary information to render trending searches, but otherwise is opaque.

Swift uses the Swift Concurrency style, Objective-C uses a callback function.

Swift

getTrendingSearches(withOptions:)

Task {
    let suggestions = try await searchRuntime.getTrendingSearches(
            withOptions: GetTrendingSearchesOptions())
}

Objective-C

getTrendingSearchesWithOptions

  [searchRuntime
      getTrendingSearchesWithOptions:
            [[GetTrendingSearchesOptions alloc] init]
                             completionHandler:^(SearchSuggestions *_Nullable suggestions,
                                                 NSError *_Nullable error) {
                              // error will be not null if there is an error.
                              // On success, suggestions will be non null.
                            }];

Display

To display trending searches chips, use the same way as the search suggestions.

Next: Display search results