EngageyaIOSSDK 0.1.2

EngageyaIOSSDK 0.1.2

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最新版本2017年8月
SwiftSwift版本3.0
SPM支持SPM

Özgür Ersil维护。



  • 作者
  • ozgur

EngageyaIOSSDK

示例

要运行示例项目,首先克隆仓库,然后在Example目录下运行pod install

要求

IOS8或更高版本

安装

EngageyaIOSSDK通过CocoaPods提供。要安装它,只需在Podfile中添加以下行:

       pod 'EngageyaIOSSDK', '~> 0.1'

使用

运行pod install后,只需使用以下命令添加EngageyaIOSSDK:

       import EngageyaIOSSDK

使用ID定义与EngageyaIOSSDK的连接,并设置您的字典键为所需的值

         self.engageya = EngageyaIOSSDK(pubid:"xxx",webid:"xxx",widid:"xxx")

         
         let appSettings:[String:Any] = [
                    "titlePaddingLeft":5,
                    "titlePaddingTop":0,
                    "imagePaddingLeft":2,
                    "imageWidth": 75,
                    "imageHeight": 50,
                    "tileHeight":120,
                    "fontFamily":UIFont.systemFont(ofSize: 13),
                    "fontSize": 13,
                    "widgetHeight" : 500,
                    "maxLines":3,
                    "fontColor": UIColor.black
                ]

使用名为getWidgetData的方法获取小部件数据准备就绪

         engageya.sharedCreatives().getWidgetData(idCollection: appId) { (widget:EngageyaWidget) in
                print("widgetTitle : \(widget.widgetTitle!)") // title of the widget
                print("recs: \(widget.boxes!)") // Array of widget elements 
         }

EngageyaWidget & EngageyaBox的响应结构

        EngageyaWidget {
            var boxes:[EngageyaBox]
            var widgetTitle:String
        }
        
        EngageyaBox {
            var clickUrl:String
            var displayName:String
            var thumbnail_path:String
            var title:String
        }

TableView使用

       self.engageya.sharedCreatives().createListView(url: url,options: appSettings) { (widget:UIView) in
            self.view.addSubview(widget)
            self.engageya.getEventManager().listenTo(eventName: "tapped", action: self.clickAction)
       }

响应的结构widget (UIView)

UITableView

CollectionView使用

       self.engageya.sharedCreatives().createCollectionView(url: url,options: appSettings) { (widget:UIView) in
            self.view.addSubview(widget)
            self.engageya.getEventManager().listenTo(eventName: "tapped", action: self.clickAction)
       }

响应的结构widget (UIView)

UICollectionView

事件

点击

       self.engageya.getEventManager().listenTo(eventName: "tapped", action: self.clickAction)
      func clickAction(information:Any?){
              if let box = information as? EngageyaBox {
                  if let displayName = box.displayName {
                      print("this is an ad \(displayName)")
                      let url = "https:\(box.clickUrl!)"
                      if #available(iOS 9.0, *) {
                          let svc = SFSafariViewController(url: NSURL(string: url)! as URL)
                          self.present(svc, animated: true, completion: nil)
                      } else {
                          adWebview = UIViewController()
                          let webView:UIWebView = UIWebView(frame: UIScreen.main.bounds)
                          webView.delegate = self
                          webView.loadRequest(URLRequest(url: URL(string: url)!))
                          let newBackButton = UIButton(frame: CGRect(x: 5, y: 5, width: 30 , height: 30))
                          newBackButton.backgroundColor = UIColor.black
                          newBackButton.setTitle("X", for: .normal)
                          newBackButton.layer.cornerRadius = 2
                          newBackButton.addTarget(self, action: #selector(self.backPressed(sender:)), for: .touchDown)
                          adWebview?.view.addSubview(webView)
                          adWebview?.view.addSubview(newBackButton)
                          self.present(adWebview!, animated: true, completion: {
                              print("moved")
                          })
                      }
                   }
                  else{
                      print("this is not an ad \(box.url!)")
                  }
              }
      }

可选参数

        static var imageWidth = 80.0
        
        static var imageHeight = 80.0
        
        static var imagePaddingLeft = 0.0
        
        static var imagePaddingTop = 0.0
        
        static var titlePaddingLeft = 0.0
        
        static var titlePaddingTop = 0.0
        
        static var tilePadding = 10.0
        
        static var tileRowCount = 2
        
        static var fontSize:Int?
        
        static var fontFamily:UIFont?
        
        static var widgetHeight:Int?
        
        static var tileHeight = 100.0
        
        static var maxLines = 2
        
        static var direction:Align = .vertical
        
        static var fontColor:UIColor = UIColor.black

作者

ozgur, [email protected]

许可证

EngageyaIOSSDK可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。