Messaging Methods


The SDK initialization is done only once. When instantiating the class, it will verify all mandatory preconditions have been met. For example, it is able to find the bundle file, open the device database file, and more. If any of the preconditions are not met, it will return nil and the SDK cannot be used.

Initialize with credentials and the delegate

Returns nil if class cannot be initialized.

public init?(consumerProperties: MessagingConsumerProperties, delegate: MessagingDelegate?)
consumerPropertiesMessagingConsumerProperties to use when authenticating with Contact At Once servers
delegateThe MessagingDelegateOptional

Unregister for push notifications, close conversations, and remove all persistent data for conversations

This is useful for testing purposes.

public func reset(completion: @escaping () -> Void, failure: @escaping (_ error: Error) -> Void)
completionClosure that is called when the log out has successfully completed
failureClosure that is called with Error when the log out failed


Show the conversation using the passed information

public func showConversation(for referenceID: String, name: String, with initialUserText: String? = nil, in viewController: UIViewController? = nil)
for referenceIDThe referenceID to use when showing the conversation
nameName to display at the top of the screen
with initialUserTextThe text to place in the text input fieldThis field optional with a default value of nil
in viewControllerEnclosing UIViewController to display the conversation inThis field optional with a default value of nil

Display all open conversations

On plus size devices in landscape orientation or tables, the list of conversations and the associated conversation will be shown side-by-side.

public func showAllConversations()

Push Notifications


Register this device with the ContactAtOnce servers to receive push notifications.

public func registerForPushNotifications(deviceToken: Data)
deviceTokenToken received by the didRegisterForRemoteNotificationsWithDeviceToken method call

Determine if a notification is a Messaging notification

public func isMessagingNotification(_ notification: UNNotification) -> Bool

– returns: Bool

Handle the push notification on behalf of the app

If the notification is determined to be from Messaging, the NotificationDelegate.didReceiveMessagingPushNotification method is called.

public func handlePushNotification(_ notification: UNNotification)

– parameter notification: The notification received by the app.

notificationThe notification received by the app


Subscribe to a given level of logging

public func subscribeLogEvents(_ logLevel: LogLevel, logEvent: @escaping LogEventClosure)
logLevelThe level of logging desired
logEventClosure to be called with each event