複数のクライアント ID

現在、1 つのクライアント ID でサポートできる検索機能は 1 つだけです。アプリで複数の検索機能を使用する場合、複数のクライアント ID を使用する必要があります。また、アプリの異なるエントリ ポイントで同じ検索機能を使用する場合も、トラフィックを区別するために、エントリ ポイントごとに異なるクライアント ID を使用する必要があります。

各リクエストに対して、GetSearchSuggestionsOptionsGetTrendingSearchesOptions、または GetSearchContentOptions でクライアント ID を事前に設定できます。この ID は、Info.plist ファイルのデフォルトのクライアント ID をオーバーライドします(このリクエストに限ります)。

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