iOS Lib Overview

Monterosa / Interaction Cloud (M/IC) was previously known as LViS. As such, you will find API documentation using the term.

Add to project

Add to your Cartfile file

git "git@gitlab.monterosa.co.uk:mobile/lvis_ios.git" "master"

Dependencies

The LViS library internally depends on Enmasse library and its dependencies

git "git@gitlab.monterosa.co.uk:mobile/enmasse_ios.git" "swift_3"
github "SwiftyJSON/SwiftyJSON" ~> 3.1.4
github "Alamofire/Alamofire" == 4.8.0

LViS library structure

There are 4 basic blocks that you need to work with:

  • LViS - is an entry point to work with LViS lib

  • Project - is an entity that represents an 'LViS Project'

  • Event - is an entity that represents an 'LViS Event'

  • Elements - are entities that represent 'LViS Elements'

How to use

To listen to LViS changes you need to set delegate:

LViS.sharedInstance.delegate = self

Where LViSDelegate is

public protocol LViSDelegate: class {
func onInitialized(_ reinitialize: Bool)
func onScheduleReinitialize(_ delay: Double)
func onEventPublished(_ event: Event)
func onSettingsChanged()
func onMessageReceived(_ message: Message)
}

LViS needs to be initialized with projectUuid and host

func setProject(host: String, projectuuId: String)

It's possible to load App Setup before connecting to LViS

func loadSettings(_ completion: @escaping ((_ settings: JSON?, _ error: Error?) -> Void))

To open LViS

func open()

After you've connected, you can get all events

func getAllEvents() -> [Event]

To subscribe to an event

func subscribe(_ event: Event, completion: @escaping ((_ success: Bool, _ error: Error?) -> Void))

When you've subscribed to event you can listen to its changes:

open var onUpdated: (() -> Void)?
open var onStateChanged: ((Event.State) -> Void)?
open var onElementPublished: ((Element) -> Void)?
open var onElementUpdated: ((Element) -> Void)?
open var onElementRevoked: ((Element) -> Void)?

From an event you can get all elements that are created inside. You can listen to each element's changes. For example, to listen to Regular poll's changes:

if let regularPoll = element as? BasePoll {
regularPoll.onVote = {}
regularPoll.onResults = {
let results = regularPoll.results
let resultsPerSource = regularPoll.resultsPerSource
let votersPerSource = regularPoll.votersPerSource
}
regularPoll.onStateChanged = { state in
}
}

After you've done with LViS you need to close it to clean resources:

func close()

If you need to manage logs:

Log.enableTags(tags: [String]) //Supported tags are [String(TransportApi), String(Enmasse), String(LViS)]
Log.onLogged = { logMessage in
}

Changelog

https://gitlab.monterosa.co.uk/mobile/lvis_ios/tags