Receber tendências
Para acessar as pesquisas em alta, chame o método getTrendingSearches
no
ContextualSearchRuntime
. Esse método usa uma única
GetTrendingSearchesOptions,
em que você pode especificar o número máximo de tendências retornadas.
O objeto SearchSuggestions
retornado não contém propriedades
acessíveis. Ele contém todas as informações necessárias para renderizar as pesquisas
em alta, mas é opaco em outros aspectos.
O Swift usa o estilo de simultaneidade do Swift, e o Objective-C usa uma função de callback.
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
Para mostrar os ícones de pesquisa de tendências, use o mesmo caminho que as sugestões de pesquisa.