SCSChat
@interface SCSChat : NSObject
The SCSChat
class is the core interface to the chat SDK.
This object manages the flow of chat sessions throughout the lifetime of the app.
For UI-related chat functionality, see SCSChatInterface
.
To get an instance of this class, use the SCServiceCloud.chatCore
property
on +[SCServiceCloud sharedInstance]
.
SCSChat
conforms to a multicast delegate model for messaging. Any class that
implements the SCSChatSessionDelegate
protocol can be added to a list of delegates to
receive session-related messages asynchronously using -addDelegate:
Any class that
implements the SCSChatEventDelegate
protocol can be added to a list of delegates to
receive general event messages asynchronously using -addEventDelegate:
See
SCSChatInterface
-
Notification identifier that is prepended to all push and local notifications generated by chat session. This can be used to differentiate notifications generated by chat from those generated by the host application.
Declaration
Objective-C
+ (NSString *)notificationIdentifier;
Swift
class func notificationIdentifier() -> String!
-
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 }
-
A reference to a chat session, which provides realtime information about the current state of the chat session.
Declaration
Objective-C
@property (readonly, strong, nonatomic) NSObject<SCSChatSession, SCSChatSessionInfo> *session;
-
Starts a chat session. Use this method if you intend to display your own UI. If you want to start a session with the default Snap-ins UI, see
-[SCSChatInterface showChatWithConfiguration:]
.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. -
Starts a chat session. Use this method if you intend to display your own UI. If you want to start a session with the default Snap-ins UI, see
-[SCSChatInterface showChatWithConfiguration:]
.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 that 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 isnil
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
id
implementing theSCSChatSessionDelegate
protocol to the list of delegates to notify.Declaration
Objective-C
- (void)addDelegate:(id<SCSChatSessionDelegate>)delegate;
Parameters
delegate
id
instance to add. -
Adds an instance of an
id
implementing theSCSChatSessionDelegate
protocol to the list of delegates to notify.Declaration
Objective-C
- (void)addDelegate:(id<SCSChatSessionDelegate>)delegate queue:(dispatch_queue_t)queue;
Parameters
delegate
id
instance to add.queue
dispatch_queue_t
you wish your events to be called back on. -
Removes an instance of an
id
implementing theSCSChatSessionDelegate
protocol from the list of delegates to notify.Declaration
Objective-C
- (void)removeDelegate:(id<SCSChatSessionDelegate>)delegate;
Parameters
delegate
id
instance to remove. -
Adds an instance of an
id
implementing theSCSChatEventDelegate
protocol to the list of delegates to notify.Declaration
Objective-C
- (void)addEventDelegate:(id<SCSChatEventDelegate>)delegate;
Parameters
delegate
id
instance to add. -
Adds an instance of an
id
implementing theSCSChatEventDelegate
protocol to the list of delegates to notify.Declaration
Objective-C
- (void)addEventDelegate:(id<SCSChatEventDelegate>)delegate queue:(dispatch_queue_t)queue;
Parameters
queue
dispatch_queue_t
you wish your events to be called back on. -
Removes an instance of an
id
implementing theSCSChatEventDelegate
protocol from the list of delegates to notify.Declaration
Objective-C
- (void)removeEventDelegate:(id<SCSChatEventDelegate>)delegate;
Parameters
delegate
id
instance to remove.