Multiple client ids
Stay organized with collections
Save and categorize content based on your preferences.
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.
}];
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-05 UTC."],[[["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`."]]],["Each search feature in an app requires a unique client ID. Using multiple search features or the same feature at different entry points necessitates distinct client IDs to track traffic. Client IDs can be set per request using `GetSearchSuggestionsOptions`, `GetTrendingSearchesOptions`, or `GetSearchContentOptions`, overriding the default ID. The provided examples show setting a client ID within `GetSearchSuggestionsOptions` in Swift and Objective-C.\n"]]