LocalMeasureWidgetKit 0.1.22

LocalMeasureWidgetKit 0.1.22

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2016
SPMSupports SPM

Maintained by solal.



 
Depends on:
Alamofire~> 3.3
ObjectMapper~> 1.2
 

Local Measure

Local Measure Widget Kit

Quickly and easily integrate your Local Measure widgets to your app.


Features

  • [x] Get a list of your widgets as an array of LMWidget.
  • [x] Get a list of a widget’s posts as an array of LMPost.


Requirements

  • iOS 8.0+
  • Xcode 7.3+


Get in touch

If you are a Local Measure customer and need help setting up your widget integration, please get in touch with [email protected]

If your are not a Local Measure client, you will find our contact page here: getlocalmeasure.com/contact


Installation


Usage

Initial setup

Start by importing the LocalMeasureWidgetKit module in your AppDelegate

import LocalMeasureWidgetKit

In your func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool, call func setup(userHash: String) passing your user hash as an argument.

This will store your user hash so you don’t have to pass it every time you make a request to the Local Measure API.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  LMWidgetKit().setup("<USER_HASH>")
  return true
}

Listing widgets

To get your list of widgets you simply need to call widgets(success: (widgets: [LMWidget]) -> Void, failure: (error: NSError) -> Void) and pass it both a success and failure closure to handle the possible results.

LMWidgetKit().widgets({ (widgets) -> Void in
  print(widgets)
}, failure: { (error) -> Void in
  print(error)
})

Listing a widget’s posts

To list a widget’s posts, call func posts(widgetHash: String, success: (posts: [LMPost]) -> Void, failure: (error: NSError) -> Void), pass it the widget’s hash and both a success and failure closure to handle the possible results.

LMWidgetKit().posts("<WIDGET_HASH>", success: { (posts) -> Void in
  print(posts)
}, failure: { (error) -> Void in
  print(error)
})


Detailed documentation

A detailed documentation of the LMWidgetKit class and the module’s types can be found here. (work in progress)