Wiele identyfikatorów klienta

Obecnie jedno identyfikator klienta może obsługiwać tylko jedną funkcję wyszukiwania. Jeśli chcesz korzystać w aplikacji z kilku funkcji wyszukiwania, musisz użyć kilku identyfikatorów klienta. Jeśli chcesz używać tej samej funkcji wyszukiwania w różnych punktach wejścia w aplikacji, musisz też używać różnych identyfikatorów klienta dla każdego z nich, aby odróżnić te punkty.

W przypadku każdej prośby możesz aktywnie ustawić identyfikator klienta w polu GetSearchSuggestionsOptions, GetTrendingSearchesOptions lub GetSearchContentOptions. Ten identyfikator zastąpi domyślny identyfikator klienta w pliku Info.plist (tylko w przypadku tej prośby).

Swift

getSearchSuggestions(withOptions:)

Task {
    let options = GetSearchSuggestionsOptions(withTextContext:['Sample Query', 'Another query string'])
    options.clientId = "client id"
    let suggestions = try await searchRuntime.getSearchSuggestions(
            withOptions: options)
}

Objective-C

getSearchSuggestionsWithOptions

  GetSearchSuggestionsOptions *options = [[GetSearchSuggestionsOptions alloc] initWithTextContext: @[@'Sample Query', @'Another query string' ]];
  options.clientId = [NSString stringWithFormat:@"client id"];
  [searchRuntime
      getSearchSuggestionsWithOptions:options
                             completionHandler:^(SearchSuggestions *_Nullable suggestions,
                                                 NSError *_Nullable error) {
                              // error will be not null if there is an error.
                              // On success, suggestions will be non null.
                            }];