การค้นหาที่มาแรง

รับการค้นหาที่มาแรง

หากต้องการรับการค้นหาที่มาแรง ให้เรียกใช้เมธอด getTrendingSearches ใน ContextualSearchRuntime เมธอดนี้ใช้ GetTrendingSearchesOptions รายการเดียว ซึ่งคุณสามารถระบุจำนวนสูงสุดของการค้นหาที่มาแรงที่จะแสดงได้

ออบเจ็กต์ SearchSuggestions ที่แสดงผลจะไม่มีพร็อพเพอร์ตี้ที่เข้าถึงได้ โดยจะมีข้อมูลที่จำเป็นทั้งหมดในการแสดงผลการค้นหาที่มาแรง แต่จะไม่มีข้อมูลอื่นๆ

Swift ใช้สไตล์การทำงานพร้อมกันของ Swift ส่วน Objective-C ใช้ฟังก์ชัน Callback

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.
                            }];

ดิสเพลย์

หากต้องการแสดงชิปการค้นหาที่มาแรง ให้ใช้วิธีเดียวกับคำแนะนำในการค้นหา

ถัดไป: แสดงผลการค้นหา