VelezaSDK 0.2.0

VelezaSDK 0.2.0

Maintained by Vytautas Povilaitis.



 
Depends on:
PINRemoteImage= 3.0.0-beta.13
DTPhotoViewerController~> 1.2
Amplitude-iOS~> 4.0.4
 

VelezaSDK 0.2.0

  • By
  • Vytautas Povilaitis

Veleza SDK

SDK with integratable Veleza UGC widgets

Integration

To start working with SDK, you must initialize it first. To do that, call VelezaSDK.initialize(clientId:) in your AppDelegate method func application(application, didFinishLaunchingWithOptions) and pass your client ID:

import VelezaSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    ...

    func application(
        _ application: UIApplication, 
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        
        VelezaSDK.initialize(clientId: "[your-client-id]")
        
        return true
    }
    
    ...
}

If you don't have client ID, you can obtain it from https://veleza.com/business or by contacting us at [email protected]

Photos & Surveys

Photos & Surveys widget displays people photos with looks with a given product, and survey ratings about various features of the product.

To use this widget, add VelezaSurveysPhotosWidget view to your controller and set product's GTIN:

import VelezaSDK

...

let widget = VelezaSurveysPhotosWidget()

view.addSubview(widget)
/** ... add view constraints ... */

/** Set product GTIN.
 *  Once this property is set, widget will request information from API and display it.
 */
widget.identifier = "00689304051019"

If Veleza does not have the requested product or any UGC associated with it, widget won't display anything. Sometimes you may want to do something if widget has no information to display. To do that, you may use VelezaWidgetDelegate protocol. This protocol requires to implement 2 methods:

...
    widget.delegate = self
...

    /** 
     *  This method is called once widget got the response from API
     */
    func velezaWidget(_ widget: VelezaWidget, shouldBeDisplayed: Bool) {
    
        /**
         *  Hide activity indicator here, etc.
         */
        
        if shouldBeDisplayed {
            /**
             *  Widget is ready to be displayed
             */
        }
        else {
            /**
             *  Widget won't display anything, display something else here
             */
        }
    }

    /** 
     *  This method is called when widget constraints has been updated 
     *  and container should be updated.
     */
    func velezaWidget(needsLayoutUpdateFor widget: VelezaWidget) {
        /** 
         *  Call layoutIfNeeded() on container or do some other layout things here.
         *  For example, update UITableView constraints:
         */
        self.tableView.beginUpdates()
        self.tableView.endUpdates()
    }
    

To see more ways to use the widget and it's configurations, look into example project included in this repository. Example project contains examples how to use widget in UITableView & displays examples of different configurations.

Installation

CocoaPods

Add VelezaSDK to your Podfile and run pod install:

pod 'VelezaSDK'