Messaging Methods
Initialize
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?)
Parameter | Description | Notes |
---|---|---|
consumerProperties | MessagingConsumerProperties to use when authenticating with Contact At Once servers | |
delegate | The MessagingDelegate | Optional |
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)
Parameters | Description | Notes |
---|---|---|
completion | Closure that is called when the log out has successfully completed | |
failure | Closure that is called with Error when the log out failed |
Conversations
Show the conversation using the passed information
public func showConversation(for referenceID: String, name: String, with initialUserText: String? = nil, in viewController: UIViewController? = nil)
Parameters | Description | Notes |
---|---|---|
for referenceID | The referenceID to use when showing the conversation | |
name | Name to display at the top of the screen | |
with initialUserText | The text to place in the text input field | This field optional with a default value of nil |
in viewController | Enclosing UIViewController to display the conversation in | This 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
Registration
Register this device with the ContactAtOnce servers to receive push notifications.
public func registerForPushNotifications(deviceToken: Data)
Parameter | Description | Notes |
---|---|---|
deviceToken | Token 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.
Parameter | Description | Notes |
---|---|---|
notification | The notification received by the app |
Logging
Subscribe to a given level of logging
public func subscribeLogEvents(_ logLevel: LogLevel, logEvent: @escaping LogEventClosure)
Parameters | Description | Notes |
---|---|---|
logLevel | The level of logging desired | |
logEvent | Closure to be called with each event |