Chat Provider for PubNub Chat Components for iOS
ChatProvider is the general interface for UI and data operations across the component library with many objects implemented as Generics.
ChatProvider assures an overarching
Type structure to coordinate the underlying data, services, themes, and view models.
You can configure
ChatProvider using the following parameters.
Required parameters don't have default values. If a parameter has a default value, it's optional.
|Configuration used when creating or connecting to the local |
|n/a||Configuration that's used to create a managed |
Chat components rely on a local
CoreData instance to manage the flow of data to the components. Network data, also known as
Model objects, is fetched from remote APIs and then converted to
Managed objects for storage inside of the
CoreData instance. Meanwhile, the UI components create local connections to the
CoreData instance to populate their views with data.
CoreData automatically updates the displayed data as it changes or as new data is added.
To learn more about
CoreData, refer to the official Apple docs.
Chat components are configured with a predefined Managed Object Model that define the
NSManagedObject objects that implement the default
To allow for the customization of data, the default
Managed object schema can be replaced if the custom schema implements the
The following table describes the relationships between the
|Default Managed object||ManagedChatEntities protocol||Model object||Generic custom data||Description|
|Channel data objects|
|User data objects|
|Relationship between channel and user data that also tracks presence.|
|Message data objects|
|Message actions data objects|
This example creates default
ChatProvider using the default PubNub
var pubnubConfig = PubNubConfiguration(
let chatProvider = ChatProvider<VoidCustomData, PubNubManagedChatEntities>(
You can use a
typealias to make typing out the full
Generic object name easier. For example, the above
ChatProvider object has a public
PubNubChatProvider is interchangeable with any instance of
ChatProvider<VoidCustomData, PubNubManagedChatEntities>. To do this in your code, follow the structure below:
public typealias PubNubChatProvider = ChatProvider<VoidCustomData, PubNubManagedChatEntities>
A reference to
ChatProvider is passed to the UI components and can be used to provide more rich functionality using the following providers.
Provides methods you can use to store data into the
CoreData instance. This includes convenience methods for pagination and auto response storage of PubNub API methods and a subscription listener that stores subscribe events.
Provides access to the
PubNub instance used by chat components with responses conforming to
Model data used by
ChatProvider. Use it to make direct calls to
PubNub APIs without storing the response. You can still store the response afterward using the corresponding
Provides a template that can be used to modify the theme used by chat components. The template consists of the following themes: