VivochaContact
@interface VivochaContact : VivochaContactInfo
This object represent the actual contact.
-
@property BOOL isShowingChat;Returns YES if the chat view is showing
-
@property (nonatomic) BOOL isTerminated;Returns YES if the contact has been terminated
-
@property (nonatomic) BOOL chatEndedByAgent;Returns YES if the contact has been closed by the agent
-
@property (nonatomic, strong) NSDate *startDate;Returns the contact start date.
-
- (void)connect;Creates and connects the communication stream.
-
- (void)terminate;Terminates a contact, hides the chat view and disconnects the communication stream.
-
- (void)terminateHidingView:(BOOL)hide;Terminates a contact, disconnects the communication stream and if the passed parameter is YES, hides the chat view.
Parameters
hideYES to hide the chat, NO to keep it open.
-
- (BOOL)hasUserAuthorizedScreenshotSession;Returns YES if user has authorized screenshot session, NO otherwise
-
- (void)stopScreenshotSession;Stop the current screenshot session
-
- (void)sendBackground;Sends a background notification to the server in order to enable the push notifications.
-
- (void)showView:(BOOL)animated;Shows the chat view.
Parameters
animatedYES if you want an animation, NO otherwise.
-
- (void)hideView:(BOOL)animated;Hides the chat view.
Parameters
animatedYES if you want an animation, NO otherwise
-
- (void)sendTextMessage:(VivochaMessage *)message;Sends a VivochaMessage through the communication stream.
Parameters
messagethe message.
-
- (void)sendReadReceiptForMessage:(VivochaMessage *)message;Sends a READ receipt for the given VivochaMessage through the communication stream.
Parameters
messagethe message.
-
- (void)sendReadReceiptForMessageId:(NSString *)messageId;Sends a READ receipt for the given message ID through the communication stream.
Parameters
messageIdthe message ID.
-
- (void)sendReadReceiptForChatObject:(VivochaChatObject *)chatObject;Sends a READ receipt for the given VivochaChatObject through the communication stream.
Parameters
chatObjectthe chat object.
-
- (NSString *)sendMessage:(NSString *)body type:(NSString *)type payload:(NSString *)payload;Sends a message through the communication stream.
Parameters
bodythe text the message will be created with
typethe type of the message
payloadthe additional payload that will be carried by the message
Return Value
the message id.
-
- (void)sendAttachmentWithUrl:(NSString *)url referenceId:(NSString *)referenceId title:(NSString *)title mimetype:(NSString *)mimetype description:(NSString *)description fileSize:(int)fileSize;Sends an attachment through the connection stream
Parameters
urlthe attachment remote url
referenceIda reference id for the attachment. If null, one will be generated.
titlethe attachment original filename - mandatory
mimetypethe attachment mime-type - mandatory
descriptionthe attachment description
fileSizethe attachment file size
-
- (void)sendChatState:(BOOL)isTyping;Sends a ‘composing’/‘paused’ message through the communication stream.
Parameters
isTypingIf YES the message will be ‘composing’, otherwise it will be ‘paused’.
-
- (void)sendCustomAction:(VivochaCustomAction *)action;Sends a custom action to the agent desktop through the communication stream.
Usage example:
//Send a custom action VivochaCustomAction *userLoggedIn = [VivochaCustomAction actionWithName:@"userLoggedIn" andJSON:@{ @"userID" : [MyApp getUserId], @"eventKind" : @"login", @"date" : [NSDate date] }]; [[Vivocha contact] sendCustomAction:userLoggedIn];Parameters
actionthe custom action.
-
- (VivochaAgent *)agent;If an agent accepts the contact, this method will return an object containing the name and the avatar (if present) of the current agent.
Return Value
the agent.
-
- (NSInteger)getUnreadMessagesCount;Returns the number of messages that are still not marked as read by the Agent.
-
- (void)addChatConnectionStateBlock:(VivochaChatConnectionStateBlock)block withOwner:(id)owner;Adds a connection’s state change listener.
Parameters
blockthe listener block.
ownerthe owner object, usually self, where you are calling this method.
-
- (void)unregisterFromConnectionStateBlock:(id)owner;Removes the connection’s state change listener registered from the owner object.
Parameters
ownerthe owner object, usually self, where you are calling this method.
-
- (BOOL)isWaitingForTransfer;Returns YES if the contact is being transfered to another Agent.
-
- (void)startWebRTCWithAudio:(BOOL)localAudio andFrontCamera:(BOOL)frontCamera andBackCamera:(BOOL)backCamera andRemoteAudio:(BOOL)rAudio andRemoteVideo:(BOOL)rVideo andCallback:(VivochaMediaCallback *)cb;Initiate a WebRTC call with the Agent.
Parameters
localAudiothe local audio is enabled
frontCamerathe local video is enabled and the source will be the front camera
backCamerathe local video is enabled and the source will be the back camera
rAudiothe agent audio is required
rVideothe agent video is required
cbthe callback to be notified of every state of the current call
-
- (void)sendProtocolRequest:(VivochaProtocolRequest *)request withBlock:(void (^)(VivochaProtocolRequest *, VivochaProtocolResponse *))block;Sends a request using the Vivocha Protocol.
Parameters
requestthe request object
blockthe result block, it contains both the request and the response
-
- (void)sendProtocolRequest:(VivochaProtocolRequest *)request withBlock:(void (^)(VivochaProtocolRequest *, VivochaProtocolResponse *))block andQueue:(dispatch_queue_t)queue;Sends a request using the Vivocha Protocol. The result block will be executed in the given queue.
Parameters
requestthe request object
blockthe result block, it contains both the request and the response
queuethe queue where the result block will be execute
-
- (void)sendProtocolRequest:(VivochaProtocolRequest *)request timeout:(NSTimeInterval)timeout withBlock:(void (^)(VivochaProtocolRequest *, VivochaProtocolResponse *))block andQueue:(dispatch_queue_t)queue;Sends a request using the Vivocha Protocol. The result block will be executed in the given queue.
Parameters
requestthe request object
timeoutthe request timeout, in seconds
blockthe result block, it contains both the request and the response
queuethe queue where the result block will be execute
-
- (void)sendProtocolResponse:(VivochaProtocolResponse *)response;Sends a response using the Vivocha Protocol.
Parameters
responsethe response object
-
- (void)hideView:(BOOL)animated andCompletionBlock:(void (^)(void))completion;Hides the chat view.
Parameters
animatedthe chat view will be hidden with an animation
completionthe completion will be executed after the chat view hides.
-
- (void)manageBackground;Based on the contact duration and if the agent has joined, decides if the contact should be terminated or if the push notifications need to be enabled. It is called when a
UIApplicationDidEnterBackgroundNotificationnotification is fired by the operating system. -
- (NSInteger)getDuration;Returns the contact duration, in seconds.
-
- (VivochaMedia *)getMedia;Returns the current media state.