SCSChat
@interface SCSChat : NSObject
The SCSChat
class is the main interface to the Live Agent Chat SDK.
This object manages the flow of Chat sessions throughout the lifetime of the app.
To get an instance of this class, use the SCServiceCloud.chat
property
on +[SCServiceCloud sharedInstance]
.
SCSChat
conforms to a multicast delegate model for messaging. Any class which
implements the SCSChatDelegate
protocol can be added to a list of delegates to
receive messages asynchronously.
For UI-related chat features, see SCSChatInterface
.
See
SCSChatInterface
-
A reference to the
SCSChatConfiguration
object provided to the session on start.Declaration
Objective-C
@property (readonly, strong, nonatomic) SCSChatConfiguration *configuration;
Swift
var configuration: SCSChatConfiguration! { get }
-
This method begins the process of starting a Live Agent Chat session.
Equivalent to invoking
-startSessionWithConfiguration:completion:
and providing anil
block.Declaration
Objective-C
- (void)startSessionWithConfiguration:(SCSChatConfiguration *)config;
Swift
func startSession(with config: SCSChatConfiguration!)
Parameters
config
The
SCSChatConfiguration
object which represents the session configuration. -
This method begins the process of starting a Live Agent Chat session.
Note
Calling
-stopSession
at any point after calling-startSessionWithConfiguration:
will not necessarily terminate a session in progress. Once the user has moved past the pre-chat phase, this will trigger a prompt asking the user if they wish to terminate the session.Declaration
Objective-C
- (void)startSessionWithConfiguration:(SCSChatConfiguration *)config completion:(__strong SCSChatCompletionHandler)block;
Swift
func startSession(with config: SCSChatConfiguration!, completion block: SCSChatCompletionHandler!)
Parameters
config
The
SCSChatConfiguration
object which represents the session configuration.block
Completion block which will be executed when the session has been fully connected to all services. When the block is executed the session is active and waiting for an agent to join. The
NSError
returned in the block will benil
on success. -
Stops an active or connecting session.
If the user has not moved past the pre-chat phase, this will immediately terminate the session and clean up all resources.
Equivalent to invoking
-stopSessionWithCompletion:
and providing anil
block.Declaration
Objective-C
- (void)stopSession;
Swift
func stopSession()
-
Stops an active or connecting session.
If the user has not moved past the pre chat phase this will immediately terminate the session and clean up all resources.
Declaration
Objective-C
- (void)stopSessionWithCompletion:(__strong SCSChatCompletionHandler)block;
Swift
func stopSession(completion block: SCSChatCompletionHandler!)
Parameters
block
Completion block which will be executed when the session has fully stopped, and all connected services have been torn down. The
NSError
returned in the block will benil
on success. -
Queries Live Agent to determine agent availability to accept a chat session.
Declaration
Objective-C
- (void)determineAvailabilityWithConfiguration:(SCSChatConfiguration *)config completion: (__strong SCSChatAvailabilityHandler) block;
Swift
func determineAvailability(with config: SCSChatConfiguration!, completion block: SCSChatAvailabilityHandler!)
Parameters
config
The
SCSChatConfiguration
object which represents the session configuration.block
The completion block that executes when the availability response returns.
-
Adds an instance of an
NSObject
implementing theSCSChatDelegate
protocol to the list of delegates to notify.Declaration
Objective-C
- (void)addDelegate:(NSObject<SCSChatDelegate> *)delegate;
Parameters
delegate
NSObject
instance to add. -
Removes an instance of an
NSObject
implementing theSCSChatDelegate
protocol from the list of delegates to notify.Declaration
Objective-C
- (void)removeDelegate:(NSObject<SCSChatDelegate> *)delegate;
Parameters
delegate
NSObject
instance to remove.