v24
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
1
git "[email protected]:mobile/lvis_ios.git" "master"
Copied!

Dependencies

The LViS library internally depends on Enmasse library and its dependencies
1
git "[email protected]:mobile/enmasse_ios.git" "swift_3"
2
github "SwiftyJSON/SwiftyJSON" ~> 3.1.4
3
github "Alamofire/Alamofire" == 4.8.0
Copied!

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:
1
LViS.sharedInstance.delegate = self
Copied!
Where LViSDelegate is
1
public protocol LViSDelegate: class {
2
func onInitialized(_ reinitialize: Bool)
3
func onScheduleReinitialize(_ delay: Double)
4
func onEventPublished(_ event: Event)
5
func onSettingsChanged()
6
func onMessageReceived(_ message: Message)
7
}
Copied!
LViS needs to be initialized with projectUuid and host
1
func setProject(host: String, projectuuId: String)
Copied!
It's possible to load App Setup before connecting to LViS
1
func loadSettings(_ completion: @escaping ((_ settings: JSON?, _ error: Error?) -> Void))
Copied!
To open LViS
1
func open()
Copied!
After you've connected, you can get all events
1
func getAllEvents() -> [Event]
Copied!
To subscribe to an event
1
func subscribe(_ event: Event, completion: @escaping ((_ success: Bool, _ error: Error?) -> Void))
Copied!
When you've subscribed to event you can listen to its changes:
1
open var onUpdated: (() -> Void)?
2
open var onStateChanged: ((Event.State) -> Void)?
3
open var onElementPublished: ((Element) -> Void)?
4
open var onElementUpdated: ((Element) -> Void)?
5
open var onElementRevoked: ((Element) -> Void)?
Copied!
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:
1
if let regularPoll = element as? BasePoll {
2
regularPoll.onVote = {}
3
regularPoll.onResults = {
4
let results = regularPoll.results
5
let resultsPerSource = regularPoll.resultsPerSource
6
let votersPerSource = regularPoll.votersPerSource
7
}
8
regularPoll.onStateChanged = { state in
9
}
10
}
Copied!
After you've done with LViS you need to close it to clean resources:
1
func close()
Copied!
If you need to manage logs:
1
Log.enableTags(tags: [String]) //Supported tags are [String(TransportApi), String(Enmasse), String(LViS)]
2
Log.onLogged = { logMessage in
3
}
Copied!

Changelog

Last modified 1yr ago