Wyszukiwania zyskujące popularność

Poznaj trendy

Aby uzyskać wyszukiwania zyskujące popularność, wywołaj metodę getTrendingSearches w obiekcie ContextualSearchRuntime. Ta metoda przyjmuje jeden parametr GetTrendingSearchesOptions, w którym można określić maksymalną liczbę zwracanych trendów.

Zwrócony obiekt SearchSuggestions nie zawiera żadnych właściwości dostępnych. Zawiera wszystkie informacje potrzebne do wyświetlania trendujących wyszukiwań, ale poza tym jest nieprzezroczysty.

Swift używa stylu równoczesności Swift, a Objective-C – funkcji wywołania zwrotnego.

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.
                            }];

Sieć reklamowa

Aby wyświetlić elementy wyszukiwań zyskujących popularność, użyj tego samego sposobu co w przypadku sugestii wyszukiwania.

Dalej: wyświetlanie wyników wyszukiwania