GooglePlaces Framework Reference

  • GMSPlacesClient provides methods for searching, retrieving details, and interacting with places data using the Google Places SDK for iOS.

  • Access the shared instance via [GMSPlacesClient sharedClient] and ensure all calls are made from the main thread.

  • Key functionalities include place lookups, autocomplete suggestions, photo retrieval, and current place estimation.

  • Methods utilize callbacks for asynchronous operations, invoked on the main thread unless specified otherwise.

  • Refer to the documentation for detailed information on each method, parameters, and deprecation notices.

GMSPlacesClient

@interface GMSPlacesClient : NSObject

Main interface to the Places SDK. Used for searching and getting details about places. This class should be accessed through the [GMSPlacesClient sharedClient] method.

GMSPlacesClient methods should only be called from the main thread. Calling these methods from another thread will result in an exception or undefined behavior. Unless otherwise specified, all callbacks will be invoked on the main thread.

  • Provides the shared instance of GMSPlacesClient for the Google Places SDK for iOS, creating it if necessary.

    If your application often uses methods of GMSPlacesClient it may want to hold onto this object directly, as otherwise your connection to Google may be restarted on a regular basis.

    Declaration

    Swift

    class func shared() -> Self

    Objective-C

    + (nonnull instancetype)sharedClient;
  • 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 GMSPlacesClient (e.g., in application:didFinishLaunchingWithOptions:).

    Declaration

    Swift

    class func provideAPIKey(_ key: String) -> Bool

    Objective-C

    + (BOOL)provideAPIKey:(nonnull NSString *)key;

    Return Value

    YES if the APIKey was successfully provided.

  • Provides an App Check token provider to the Google Places SDK for iOS. This should be called by your application before using GMSPlacesClient (for example, in application:didFinishLaunchingWithOptions:). If you do not provide a token provider, the SDK will not use the token provider.

    Declaration

    Swift

    class func setAppCheckTokenProvider(_ provider: any GMSPlacesAppCheckTokenProvider)

    Objective-C

    + (void)setAppCheckTokenProvider:
        (nonnull id<GMSPlacesAppCheckTokenProvider>)provider;
  • 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

    class func openSourceLicenseInfo() -> String

    Objective-C

    + (nonnull NSString *)openSourceLicenseInfo;
  • Returns the version for this release of the Google Places SDK for iOS.. For example, “1.0.0”.

    Declaration

    Swift

    class func sdkVersion() -> String

    Objective-C

    + (nonnull NSString *)SDKVersion;
  • Returns the long version for this release of the Google Places SDK for iOS.. For example, “1.0.0 (102.1)”.

    Declaration

    Swift

    class func sdkLongVersion() -> String

    Objective-C

    + (nonnull NSString *)SDKLongVersion;
  • Find Autocomplete suggestions from text query. Results may optionally be biased towards a certain location or restricted to an area. This method is non-blocking.

    The supplied callback will be invoked with an array of autocompletion suggestions upon success and an NSError upon an error.

    Declaration

    Swift

    func fetchAutocompleteSuggestions(from request: GMSAutocompleteRequest, callback: @escaping GMSAutocompleteSuggestionsCallback)

    Objective-C

    - (void)
        fetchAutocompleteSuggestionsFromRequest:
            (nonnull GMSAutocompleteRequest *)request
                                       callback:
                                           (nonnull
                                                GMSAutocompleteSuggestionsCallback)
                                               callback;

    Parameters

    request

    The GMSAutocompleteRequest request for autocomplete.

    callback

    The callback to invoke with the suggestions.

  • Gets the open status for a place.

    Gets details for a place including all properties necessary to determine GMSPlaceOpenStatus at the specified NSDate.

    This method is non-blocking.

    NOTE: It is best practice to check that opening hours are not null before passing in a GMSPlace (with opening hours already requested) to GMSPlaceIsOpenRequest. In some cases, a place may not have any opening hours data available. If a place request with the opening hours property has already been made, and opening hours are null, calling this method using the place response object will result in another billable event.

    Declaration

    Swift

    func isOpen(with isOpenRequest: GMSPlaceIsOpenRequest, callback: @escaping GMSPlaceOpenStatusResponseCallback)

    Objective-C

    - (void)isOpenWithRequest:(nonnull GMSPlaceIsOpenRequest *)isOpenRequest
                     callback:(nonnull GMSPlaceOpenStatusResponseCallback)callback;

    Parameters

    isOpenRequest

    The request to determine the open status for a given place.

    callback

    The callback to invoke with the open status response.

  • Deprecated

    This method is replaced by searchByTextWithRequest:completion: and will be removed in a future release.

    Search for places by text and restrictions. This method is non-blocking.

    Declaration

    Swift

    func searchByText(with textSearchRequest: GMSPlaceSearchByTextRequest, callback: @escaping GMSPlaceSearchByTextResultCallback)

    Objective-C

    - (void)searchByTextWithRequest:
                (nonnull GMSPlaceSearchByTextRequest *)textSearchRequest
                           callback:
                               (nonnull GMSPlaceSearchByTextResultCallback)callback;

    Parameters

    textSearchRequest

    GMSPlaceSearchByTextRequest The text request to use for the query.

    callback

    The callback to invoke with the lookup result.

  • Get a place using a request object. This method is non-blocking.

    Declaration

    Swift

    func fetchPlace(with fetchPlaceRequest: GMSFetchPlaceRequest, callback: @escaping GMSPlaceResultCallback)

    Objective-C

    - (void)fetchPlaceWithRequest:(nonnull GMSFetchPlaceRequest *)fetchPlaceRequest
                         callback:(nonnull GMSPlaceResultCallback)callback;

    Parameters

    fetchPlaceRequest

    GMSFetchPlaceRequest The fetch place request to use for the query.

    callback

    The callback to invoke with the place result.

  • Deprecated

    This API is deprecated, please use the Place Details component (https://developers.google.com/maps/documentation/places/ios-sdk/place-details-ui-kit) instead.

    Request a photo using fetch photo request. This method is non-blocking.

    Declaration

    Swift

    func fetchPhoto(with fetchPhotoRequest: GMSFetchPhotoRequest, callback: @escaping GMSFetchPhotoResultCallback)

    Objective-C

    - (void)fetchPhotoWithRequest:(nonnull GMSFetchPhotoRequest *)fetchPhotoRequest
                         callback:(nonnull GMSFetchPhotoResultCallback)callback;

    Parameters

    fetchPhotoRequest

    GMSFetchPhotoRequest The photo request to use.

    callback

    The callback to invoke with the NSURL result.

  • Deprecated

    This method is replaced by searchNearbyWithRequest:completion: and will be removed in a future release.

    Search for places near a location and restriction. This method is non-blocking.

    Declaration

    Swift

    func searchNearby(with searchNearbyRequest: GMSPlaceSearchNearbyRequest, callback: @escaping GMSPlaceSearchNearbyResultCallback)

    Objective-C

    - (void)searchNearbyWithRequest:
                (nonnull GMSPlaceSearchNearbyRequest *)searchNearbyRequest
                           callback:
                               (nonnull GMSPlaceSearchNearbyResultCallback)callback;

    Parameters

    searchNearbyRequest

    GMSPlaceSearchNearbyRequest The search nearby request to use for the query.

    callback

    The callback to invoke with the lookup result.

  • Search for places by text and restrictions. This method is non-blocking.

    Declaration

    Swift

    func searchByText(with textSearchRequest: GMSPlaceSearchByTextRequest) async throws -> GMSPlaceSearchByTextResponse

    Objective-C

    - (void)searchByTextWithRequest:
                (nonnull GMSPlaceSearchByTextRequest *)textSearchRequest
                         completion:
                             (nonnull GMSPlaceSearchByTextResponseCallback)callback;

    Parameters

    textSearchRequest

    GMSPlaceSearchByTextRequest The text request to use for the query.

    callback

    The callback to invoke with the search response.

  • Search for places near a location and restriction. This method is non-blocking.

    Declaration

    Swift

    func searchNearby(with searchNearbyRequest: GMSPlaceSearchNearbyRequest) async throws -> GMSPlaceSearchNearbyResponse

    Objective-C

    - (void)searchNearbyWithRequest:
                (nonnull GMSPlaceSearchNearbyRequest *)searchNearbyRequest
                         completion:
                             (nonnull GMSPlaceSearchNearbyResponseCallback)callback;

    Parameters

    searchNearbyRequest

    GMSPlaceSearchNearbyRequest The search nearby request to use for the query.

    callback

    The callback to invoke with the search response.

  • Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of a marker clustering library. To opt out of sending the usage attribution ID, it is safe to delete this function call or replace the value with an empty string.

    Declaration

    Swift

    class func addInternalUsageAttributionID(_ internalUsageAttributionID: String)

    Objective-C

    + (void)addInternalUsageAttributionID:
        (nonnull NSString *)internalUsageAttributionID;

    Parameters

    internalUsageAttributionId

    The usage attribution ID to add