熱門搜尋

取得趨勢

如要取得熱門搜尋,請對 ContextualSearchRuntime 呼叫 getTrendingSearches 方法。這個方法使用單一 GetTrendingSearchesOptions,其中可讓您指定傳回的發燒主題數量上限。

傳回的 SearchSuggestions 物件不含任何可存取的屬性。其中包含轉譯熱門搜尋所需的一切資訊,但沒有公開透明。

Swift 使用 Swift 並行處理樣式,Objective-C 則使用回呼函式。

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

多媒體

如要顯示熱門搜尋方塊,請使用與搜尋建議相同的方式

下一篇:顯示搜尋結果