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

ดูเทรนด์

หากต้องการดูการค้นหาที่มาแรง ให้เรียกใช้เมธอด 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.
                            }];

ดิสเพลย์

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

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