שאילתות חיפוש פופולריות

אחזור של 'הסרטונים החמים'

כדי לקבל שאילתות חיפוש פופולריות, אפשר להפעיל את השיטה getTrendingSearches במספר ContextualSearchRuntime. השיטה מקבלת אובייקט GetTrendingSearchesOptions אחד, שבו אפשר לציין את המספר המקסימלי של הטרנדים שיוחזרו.

אובייקט SearchSuggestions המוחזר לא מכיל תכונות נגישות. היא מכילה את כל המידע הנדרש כדי להציג חיפושים פופולריים, אבל חוץ מזה הוא אטום.

ב-Swift נעשה שימוש בסגנון Swift Concurrency, וב-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.
                            }];

רשת המדיה

כדי להציג צ'יפים של חיפושים פופולריים, השתמשו באותה דרך כמו בהצעות החיפוש.

השלב הבא: הצגת תוצאות חיפוש