Layer’s UI Libraries
Layer provides UI libraries to help build apps that work with Layer data. These libraries assume that you are using Layer’s SDKs directly, rather than using your own data-models, or directly using Layer’s Client API (REST API). UI Libraries serve the following goals:
- Provide a Message List that manages a list of Messages in a Conversation, mark Messages as
readwhen they become visible, page Query data as the user scrolls, and managing the scroll position, especially keeping the view pinned to the bottom to continously view new messages as they arrive.
- Provide Conversation Lists that let you scroll through and select existing Conversations
- Provide Lists of users that you can create Conversations with
Details of these components may vary, and other components may make sense depending on which framework you are using. Current UI Libraries are available in:
Using the Atlas iOS Library
Atlas is a lightweight, flexible set of user interface components designed to enable developers to quickly and easily integrate native communications experiences into their applications. It was designed and built from the ground up to integrate with LayerKit, the native iOS SDK for accessing the Layer communications platform. LayerKit provides developers with a simple, object oriented interface to the rich messaging capabilities provided by the Layer platform. Atlas, in turn, provides ready-made UI components that expose these capabilities directly to users.
Working With Atlas Components
Components in the Atlas UI Library for iOS can be broken down into three main groups: View Controllers, Views, and Models. This documentation will focus primarily on these 3 main View Controllers:
- ATLConversationListViewController: Manages a Conversation List and allows the user to select a Conversation
- ATLConversationViewController: Manages a single Conversation by displaying messages and allowing the user to send their own
- ATLParticipantTableViewController: Manages a list of users that can be selected
We recommend you subclass the Atlas classes that you intend to use. This gives you flexibility to design classes for your use cases, and interface with Atlas by inheriting methods and implementing a few data source and delegate methods.
Common LayerKit Classes
LayerKit classes commonly seen among View Controllers are described below.
The Layer Client
Most View Controllers require access to and are initialized with your single instance of the
LYRClient (LayerKit) class. You are required to initialize your client before interacting with Atlas components, however, they will remain responsive even if the client is neither connected nor authenticated.
The Query Controller
Most View Controllers list data in some form. Atlas utilizes the
LYRQueryController (LayerKit) class to manage and present the data with either a
- Atlas View Controllers are designed to initialize their query controller once during the
viewDidLoadmethod. This is the time to specify the main query you want to return.
UICollectionViewviews are updated with changes via the
Install SDK Core Components
Each query controller should only be created once for the lifetime of it’s view. If you want to change the results (such as with a filter or toggle button) you can create a separate function to update the underlying query properties and re-execute the query controller. This will ensure your data source stays in-sync with your table/collection view. Failure to follow this guideline may result in a