获取时下流行视频
如需获取热门搜索,请对 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.
}];
展示广告
如需显示热搜条状标签,请使用与搜索建议相同的方式。