الحصول على محتوى البحث
أضفنا إمكانية الحصول على واجهة مستخدم محتوى البحث في حزمة تطوير البرامج (SDK).
Search Content
هو مصطلح عام يمثّل أنواعًا متعدّدة من ميزات المحتوى، لذا يُرجى الاطّلاع على الأقسام التالية لمعرفة كيفية طلب كل نوع من ميزات المحتوى على التوالي.
تكرار البحث
استخدِم طريقة getSearchContent
في ContextualSearchRuntime
. تأخذ هذه الطريقةGetSearchContentOptions
واحدة يمكنك من خلالها تحديد النص الذي تريد استخدامه
للبحث عن محتوى. للحصول على تكرار البحث، أدخِل نص تكرار البحث
في مثيل GetSearchContentOptions
.
لا يحتوي عنصر SearchContents
المعروض على أي خصائص يمكن الوصول إليها.
يشتمل هذا القسم على جميع المعلومات الضرورية لعرض محتوى البحث،
ولكنه معتم بخلاف ذلك.
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.
}];
محتوى شبكة البحث على الشبكة الإعلانية
لعرض محتوى البحث، استخدِم الطرق التالية.
واجهة المستخدم
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];
}