PlacesClient
final class PlacesClient
extension PlacesClient : PlacesClientProtocol
Main interface to the Places SDK, used for searching and getting details about places.
This type should be accessed through PlacesClient.shared.
PlacesClient methods should only be called from the main thread. Calling these methods from
another thread will result in an exception or undefined behavior.
-
Provides the shared instance of PlacesClient for the Google Places SDK for iOS, creating it if necessary.
If your application often uses methods of PlacesClient it may want to retain this object directly, as otherwise your connection to Google may be restarted on a regular basis.
Note
Google Places SDK for iOS must be initialized via PlacesClient.provideAPIKey(…) prior to use.Declaration
Swift
@MainActor unowned static var shared: PlacesClient { get } -
Provides your API key to the Google Places SDK for iOS.
This key is generated for your application via the Google Cloud Platform Console, and is paired with your application’s bundle ID to identify it. This should be called by your application before using PlacesClient (e.g., in application:didFinishLaunchingWithOptions:).
Declaration
Swift
static func provideAPIKey(_ key: String) -> BoolReturn Value
true if the APIKey was successfully provided.
-
Returns the open source software license information for the Google Places SDK for iOS. This information must be made available within your application.
Declaration
Swift
static var openSourceLicenseInfo: String { get } -
Returns the version for this release of the Google Places SDK for iOS. For example, “1.0.0”.
Declaration
Swift
static var sdkVersion: String { get } -
Returns the long version for this release of the Google Places SDK for iOS. For example, “1.0.0 (102.1)”.
Declaration
Swift
static var sdkLongVersion: String { get } -
Gets details for a place including all fields necessary to determine if it is open at the optionally specified
Date.Declaration
Swift
func isPlaceOpen(_ placeID: String, date: Date? = nil) async -> Result<Bool?, PlacesError>Parameters
placeIDThe place ID to lookup.
dateThe optional
Dateto determine open status for. If nil, checks whether the place is open at the current time.Return Value
A
Resultwith theBool?status for the requested place, or aPlacesError. -
Gets details for a place including all fields necessary to determine if it is open at the specified
Date. Only requests additional fields if thePlacedoes not have all necessary fields, otherwiseBoolwill be returned in the callback immediately.Declaration
Swift
func isPlaceOpen(_ place: Place, date: Date? = nil) async -> Result<Bool?, PlacesError>Parameters
placeThe
Placeto lookup.dateThe optional
Dateto determine open status for. If nil, checks whether the place is open at the current time.Return Value
A
Resultwith theBool?status for the requested place, or aPlacesError. -
Search for places by text and restrictions.
Declaration
Swift
func searchByText(with request: SearchByTextRequest) async -> Result<[Place], PlacesError>Parameters
withSearchByTextRequestThe text request to use for the query.Return Value
A
Resultwith the[Place]response for the request, or aPlacesError. -
Search for places near a location and restriction.
Declaration
Swift
func searchNearby(with request: SearchNearbyRequest) async -> Result<[Place], PlacesError>Parameters
withSearchNearbyRequestThe search nearby request to use for the query.Return Value
A
Resultwith the[Place]response for the request, or aPlacesError. -
Get a place using a request object.
Declaration
Swift
func fetchPlace(with request: FetchPlaceRequest) async -> Result<Place, PlacesError>Parameters
withFetchPlaceRequestThe fetch place request to use for the query.Return Value
A
Resultwith thePlaceresponse for the request, or aPlacesError. -
Get a place using a request object.
Declaration
Swift
func fetchPhoto(with request: FetchPhotoRequest) async -> Result<UIImage, PlacesError>Parameters
withThe
FetchPhotoRequestto use for the query.Return Value
A
Resultwith theUIImageresponse for the request, or aPlacesError. -
Undocumented
Declaration
Swift
func fetchAutocompleteSuggestions(with request: AutocompleteRequest) async -> Result<[AutocompleteSuggestion], PlacesError>