GooglePlacesSwift Framework Reference

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) -> Bool

    Return 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

    placeID

    The place ID to lookup.

    date

    The optional Date to determine open status for. If nil, checks whether the place is open at the current time.

    Return Value

    A Result with the Bool? status for the requested place, or a PlacesError.

  • Gets details for a place including all fields necessary to determine if it is open at the specified Date. Only requests additional fields if the Place does not have all necessary fields, otherwise Bool will be returned in the callback immediately.

    Declaration

    Swift

    func isPlaceOpen(_ place: Place, date: Date? = nil) async -> Result<Bool?, PlacesError>

    Parameters

    place

    The Place to lookup.

    date

    The optional Date to determine open status for. If nil, checks whether the place is open at the current time.

    Return Value

    A Result with the Bool? status for the requested place, or a PlacesError.

  • Search for places by text and restrictions.

    Declaration

    Swift

    func searchByText(with request: SearchByTextRequest) async -> Result<[Place], PlacesError>

    Parameters

    with

    SearchByTextRequest The text request to use for the query.

    Return Value

    A Result with the [Place] response for the request, or a PlacesError.

  • Search for places near a location and restriction.

    Declaration

    Swift

    func searchNearby(with request: SearchNearbyRequest) async -> Result<[Place], PlacesError>

    Parameters

    with

    SearchNearbyRequest The search nearby request to use for the query.

    Return Value

    A Result with the [Place] response for the request, or a PlacesError.

  • Get a place using a request object.

    Declaration

    Swift

    func fetchPlace(with request: FetchPlaceRequest) async -> Result<Place, PlacesError>

    Parameters

    with

    FetchPlaceRequest The fetch place request to use for the query.

    Return Value

    A Result with the Place response for the request, or a PlacesError.

  • Get a place using a request object.

    Declaration

    Swift

    func fetchPhoto(with request: FetchPhotoRequest) async -> Result<UIImage, PlacesError>

    Parameters

    with

    The FetchPhotoRequest to use for the query.

    Return Value

    A Result with the UIImage response for the request, or a PlacesError.

  • Undocumented

    Declaration

    Swift

    func fetchAutocompleteSuggestions(with request: AutocompleteRequest) async -> Result<[AutocompleteSuggestion], PlacesError>