Skip to content

localmeasure/LocalMeasureWidgetKit

Repository files navigation

CocoaPods Build Status Twitter URL

Local Measure

Local Measure Widget Kit

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


Features

  • Get a list of your widgets as an array of LMWidget.
  • 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

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build LocalMeasureWidgetKit 0.1.0+.

To integrate LocalMeasureWidgetKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'LocalMeasureWidgetKit', '~> 0.1.21'

Then, run the following command:

$ pod install

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)

About

Integrate Local Measure widgets to your iOS app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published