Multiple client ids

  • By default, one client ID corresponds to one search feature in your app, necessitating multiple client IDs for utilizing various search features or entry points.

  • To differentiate traffic and functionality, employ separate client IDs for distinct search features and app entry points.

  • Developers can dynamically set a client ID for individual requests using GetSearchSuggestionsOptions, GetTrendingSearchesOptions, or GetSearchContentOptions, overriding the default ID specified in the Info.plist.

Right now one client ID can only support one search feature. If you want to use multiple search features in your app, you should use multiple client IDs. In addition, if you want to use the same search feature in different entry points in your app, you should also use different client IDs for each of them to distinguish the traffic.

For your each request, you can proactively set a client ID in GetSearchSuggestionsOptions, GetTrendingSearchesOptions or GetSearchContentOptions, and this ID will override the default client ID in the Info.plist file (only for this request).

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