TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2016 |
SPMSupports SPM | ✗ |
Maintained by solal.
Depends on: | |
Alamofire | ~> 3.3 |
ObjectMapper | ~> 1.2 |
Quickly and easily integrate your Local Measure widgets to your app.
LMWidget
.LMPost
.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
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
}
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)
})
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)
})
A detailed documentation of the LMWidgetKit
class and the module’s types can be found here. (work in progress)