急上昇を取得する
急上昇ワード検索結果を取得するには、ContextualSearchRuntime
の getTrendingSearches
メソッドを呼び出します。このメソッドは、返される急上昇の最大数を指定できる GetTrendingSearchesOptions を 1 つ受け取ります。
返される 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.
}];
ディスプレイ
急上昇検索チップを表示するには、検索候補と同じ方法を使用します。