Arama içeriğini alma
SDK'ya arama içeriği kullanıcı arayüzü alma desteği eklendi.
Search Content, birden fazla içerik türünü temsil eden genel bir terimdir. Her bir içerik türü için nasıl istekte bulunacağınızı öğrenmek üzere aşağıdaki bölümlere göz atın.
Aramayı Tekrarla
ContextualSearchRuntime üzerinde getSearchContent yöntemini çağırın. Bu yöntemde, arama içeriği almak için kullanılacak metni belirtebileceğiniz tek bir GetSearchContentOptions parametresi kullanılır. Arama tekrarı almak için arama tekrarı metnini GetSearchContentOptions örneğine iletin.
Döndürülen SearchContents nesnesi, erişilebilir özellikler içermiyor.
Arama içeriğini oluşturmak için gerekli tüm bilgileri içerir ancak aksi takdirde opak olur.
SwiftUI
Task {
let sampleSearchRepeat = "search repeat text"
let options = GetSearchContentOptions(searchRepeat: sampleSearchRepeat)
let searchContents: SearchContents =
try await contextualSearchRuntime.getSearchContent(withOptions: options)
}
Objective-C
GetSearchContentOptions *options =
[[GetSearchContentOptions alloc] initWithSearchRepeat:@"sample search repeat"];
[_contextualSearchRuntime getSearchContentWithOptions:options
completionHandler:^(SearchContents *_Nullable contents,
NSError *_Nullable error) {
// error will be not null if there is an error.
// On success, contents will be non null.
}];
Arama Ağı İçeriğini Görüntüleme
Arama içeriğini görüntülemek için aşağıdaki yöntemleri kullanın.
SwiftUI
var customizationOptions = SearchContentViewOptions()
...
VStack {
ForEach(searchContents.searchContentBlocks) { block in
SearchContentView(blockData: block, options: customizationOptions)
}
}
Objective-C
for (SearchContentBlockData *block in ((SearchContents *)_searchContents)
.searchContentBlocks) {
SearchContentViewController *blockView = [[SearchContentViewController alloc]
initWithOptions:[[SearchSuggestionsViewOptions alloc] init]];
blockView.blockData = block;
[_searchContentStackView addSubview:blockView.view];
[blockView addToViewController:self];
}