Skip to content

syte-ai/iOS-SDK

Repository files navigation

Syte iOS SDK

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Syte is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Syte', :git => 'https://github.com/syte-ai/iOS-SDK.git'

Also, it is SwiftPM supportable. Add package to project with Xcode:

https://github.com/syte-ai/iOS-SDK.git

Account Credentials

In order to use this SDK, please contact Syte for your account ID and signature.

Use the SDK

Initialization

To start using the Syte SDK, instantiate the SyteConfiguration object and pass your API credentials to its constructor. Your credentials can be found in Syte’s Platform - Settings - API Keys. Then use the created instance to set the locale.

let configuration = SyteConfiguration(accountId: <account_id>, signature: <api_signature>)
configuration.locale = <locale>

Then you'll need to initialize Syte class passing the configuration instance :

var syte: Syte? = Syte(configuration: configuration)

API used: https://cdn.syteapi.com/accounts/[account_id]

To retrieve the instance of SytePlatformSettings use the syte.getSytePlatformSettings() method.

For get recent searches:

syte.getRecentTextSearches()

For set viewed product:

syte.addViewedProduct(sku: <String>)

Get all viewed items:

syte.getViewedProducts()

Image Search

Object detection ("bounds") and a similarity search ("Items") per object detected in the image. Search can be performed with an image or image URL.

To use the image Search functionality do the following:

  1. Create dedicated class instance and pass the required data.

For Url image search:

let imageSearchRequestData = UrlImageSearch(imageUrl: <image url>, productType: <SyteProductType>)

For image search:

let imageSearchRequestData = ImageSearch(image: <UIImage>)
  1. Retrieve bounds:

For Url image search:

syte.getBoundsForImageUrl(requestData: <UrlImageSearch>) { [weak self] result in
// Handle response, result type is SyteResult<BoundsResult> 
}

For image search:

syte.getBoundsForImage(requestData: <ImageSearch>) { [weak self] result in
// Handle response, result type is SyteResult<BoundsResult> 
}
  1. Retrieve Items for a bound:
syte.getItemsForBound(bound: Bound, cropCoordinates: CropCoordinates) { result in
// Handle response
}

You can pass CropCoordinates instance instead of nil here to enable the crop functionality. Example:

let coordinates = CropCoordinates(x1: 0.2, y1: 0.2, x2: 0.8, y2: 0.8) // The coordinates should be relative ranging from 0.0 to 1.0
syte.getItemsForBound(bound: <Bound>, cropCoordinates: coordinates) { result in
// Handle response, result type is SyteResult<ItemsResult> 
}

NOTE Items for the first bound will be retrieved by default. Use

urlImageSearch.retrieveOffersForTheFirstBound = false

or

imageSearch.retrieveOffersForTheFirstBound = false

to disable this behaviour. To get the items for the first bound use the

BoundsResult.firstBoundItemsResult

variable.

Product Recommendations

To use the "Recommendations" functionality, do the following:

  1. Use Syte class instance to get results for different features:
  • getSimilarProducts(similarProducts: SimilarProducts, completion: @escaping (SyteResult<SimilarProductsResult>) -> Void)
  • getShopTheLook(shopTheLook: ShopTheLook, completion: @escaping (SyteResult<ShopTheLookResult>) -> Void)
  • getPersonalization(personalization: Personalization, completion: @escaping (SyteResult<PersonalizationResult>) -> Void)

NOTE: You must add at least one product ID to use the "Personalization" functionality. To do this use the

Syte.addViewedProduct(String)

method.

Personalized ranking

Enabling the personalized ranking will attach the list of viewed products to the requests. To add a product to the list of viewed ones use the

Syte.addViewedProduct(String)

method. To enable this functionality use the

personalizedRanking = true

variable. It is supported in the following classes:

UrlImageSearch, ImageSearch, ShopTheLook, SimilarProducts

Personalized ranking is disabled by default.

Data Collection

The SDK can be used to fire various events to Syte. Example:

syte.fireEvent(EventCheckoutStart())

Text Search

The SDK can be used for the Text Search functionality.

There are 3 main features:

  1. Popular Searches. Will retrieve the list of the most popular searches.
syte.getPopularSearches(lang: String, completion: @escaping (SyteResult<[String]>) -> Void)
  1. Text search. Will retrieve the results for the specified query.
syte.getTextSearch(textSearch: TextSearch, completion: @escaping (SyteResult<TextSearchResult>) -> Void)

To retrieve a list of recent text searches use syte.getRecentTextSearches() method.

  1. Auto-complete. Text auto-completion functionality.
syte.getAutoCompleteForTextSearch("query", "en_US") { [weak self] result in
// Handle response, result type is SyteResult<AutoCompleteResult>
}

Platform settings

To retrieve the Syte Platform Settings use:

syte.getPlatformSettings(completion: @escaping (SyteResult<SytePlatformSettings>) -> Void)

Author

Artur Tarasenko, [email protected]

License

Syte is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8