File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
templates/swift/guides/search Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
2+ #if os(Linux) // For linux interop
3+ import FoundationNetworking
4+ #endif
5+
6+ import Core
7+ { {> snippets/import} }
8+
9+ func searchWithGAToken() async throws {
10+ do {
11+ {{> snippets/init} }
12+
13+ let userToken = getGoogleAnalyticsUserIdFromBrowserCookie("_ga");
14+ var searchParams = SearchSearchParams.searchSearchParamsObject(
15+ SearchSearchParamsObject(query: "<YOUR _SEARCH_QUERY >", userToken: userToken)
16+ )
17+
18+ let _: SearchResponse<Hit > = { {#dynamicSnippet} }searchWithSearchParams{ {/dynamicSnippet} }
19+
20+ let loggedInUser: String? = "..."
21+ searchParams = SearchSearchParams.searchSearchParamsObject(
22+ SearchSearchParamsObject(query: "<YOUR _SEARCH_QUERY >", userToken: loggedInUser ?? userToken)
23+ )
24+
25+ let _: SearchResponse<Hit > = { {#dynamicSnippet} }searchWithSearchParams{ {/dynamicSnippet} }
26+ } catch {
27+ print(error)
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments