Woosmap MultiSearch iOS SDK

Basics and first steps to set the MultiSearch on iOS.

  1. Installation
  2. Implementing the MultiSearch Object

Installation

You can install the SDK in three different ways.

We recommend installing the SDK via Swift Package Manager.

Swift Package Manager

To integrate Woosmap Geofencing SDK into your project using Swift Package Manager, you can add the library as a dependency in Xcode (11 and above) – see adding package dependencies to your app on Apple documentation. The package repository URL is:

        https://github.com/Woosmap/multisearch-ios

    

CocoaPods

Install CocoaPods, a dependency manager for Cocoa projects. If you don’t have an existing Podfile, run pod init in your project directory. Add the following to your Podfile: For usage and installation instructions, visit their website. To integrate Woosmap Geofencing SDK into your Xcode project using CocoaPods, specify it in your Podfile:

        pod 'Multisearch', :git => 'https://github.com/Woosmap/multisearch-ios'

    

Importing the Framework manually

  1. Unzip MultiSearch-<version>.zip.
  2. Import the MultiSearch.framework folder into your Xcode project.

If Xcode has not automatically added the correct path(s), add a project-relative path to your framework.

Implementing the MultiSearch Object

The library requires to set a key for each available API in your MultiSearch implementation, whether it’s a Woosmap API or for Google Places API.

Please refer to the documentation to get an API Key if necessary.

Additionally, for each provider configuration you can apply the same optional parameters as defined in the corresponding provider documentation.

When instantiating the Multisearch object, specify your desired autocomplete services’ API keys and the order in which these services will be called:

swift
        let localitiesProvider = ProviderConfig(searchType: .localities,
                                        key: <<woosmap_private_key>>)

let addressProvider = ProviderConfig(searchType: .address,
                                     key: <<woosmap_private_key>>)

let storeProvider = ProviderConfig(searchType: .store,
                                   key: <<woosmap_private_key>>)

let placesProvider = ProviderConfig(searchType: .places,
                                    key: <<google_api_web_key>>)


    

Then, create MultiSearch object and add the providers to it using MultiSearch.addProvider() method.

swift
        import Multisearch

private let objSearch = MultiSearch.init(debounceTime: 100)

// Order for calling multisearch api
objSearch.addProvider(config: localitiesProvider)
objSearch.addProvider(config: storeProvider)
objSearch.addProvider(config: addressProvider)
objSearch.addProvider(config: placesProvider)

    

APIs will be called based on the order in which they were provided to MultiSearch object. In above code snippet following will be the order of the APIs:

LOCALITIESSTOREADDRESSPLACES

Specify debounceTime

Debounce time is the amount of time in milliseconds the autocomplete function will wait after the last received call before executing it. If 0 is specified then autocomplete function will not wait for the execution call.

Setting up callback

MultiSearch routine returns the autocomplete and details results using block function. This block returns expected results or a Woosmap error.

Retrieve suggestions

You can retrieve suggestions from the user input by calling the autocompleteMulti method:

swift
        objSearch.autocompleteMulti(input: "paris") { (results, error) in }

    

Get Details

Finally, to get the suggestion details when a user selects one from the pick list, call the details method. This method accepts two parameters:

swift
        objSearch.details(id: "UGFyaXMsIMOObGUtZGUtRnJhbmNlLCBGcmFuY2U=", provider: .store) { (locationinfo, error) in }

    
Was this article helpful?
Have more questions? Submit a request