VelezaSDK 0.2.0

VelezaSDK 0.2.0

Vytautas Povilaitis 维护。



 
依赖关系
PINRemoteImage≥ 3.0.0-beta.13
DTPhotoViewerController~> 1.2
Amplitude-iOS~> 4.0.4
 

VelezaSDK 0.2.0

  • Vytautas Povilaitis

Veleza SDK

具有可集成 Veleza UGC 小部件的 SDK

集成

要开始使用 SDK,您必须先初始化它。为此,在您的 AppDelegatefunc application(application, didFinishLaunchingWithOptions) 方法中调用 VelezaSDK.initialize(clientId:=) 并传递您的客户端 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
    }
    
    ...
}

如果您没有客户端 ID,您可以从 https://veleza.com/business 获取它,或者通过[email protected] 联系我们。

图片 & 问卷调查

图片 & 问卷调查小部件 显示具有给定产品的照片和产品各项功能调查评分。

为了使用这个小部件,将 VelezaSurveysPhotosWidget 视图添加到您的控制器中,并设置产品的 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"

如果 Veleza 没有请求的产品或与其相关的任何 UGC,小部件将不会显示任何内容。有时,如果您想让小部件没有信息显示时执行某些操作,您可以使用 VelezaWidgetDelegate 协议。此协议需要实现 2 个方法

...
    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()
    }
    

为了了解更多使用小部件及其配置的方法,请查看包含在此存储库中的 示例项目。该示例项目包含如何在 UITableView 中使用小部件的示例以及不同配置的例子。

安装

CocoaPods

将VelezaSDK添加到您的Podfile中,然后运行pod install

pod 'VelezaSDK'