This page was last edited on December 5, 2014, at 19:24.
Comments or questions about this documentation? Contact us for support!
Use this method to restore the chat widget after page reload/navigation.
If the previous page was unloaded during the registration phase, restoreChat will try to restore the chat widget with the registration form.
restoreChat returns a "promise" object with two chainable methods: done and fail.
done
This method can be used to get access to chat session service API.
chat.restoreChat(options).done(function(session) {
// session.sendMessage, session.onAgentConnected and all other methods are at your disposal.
});
See Chat Service JS API for documentation about using the session API. If you need to access Chat Session API, you will probably want to get the access not only in cases when session is restored, but also when it is started fresh. You can use startChat's "done" callback for this. See Getting access to Chat Session API for more info.
fail
If chat restoration fails because of an error (and not because the chat session does not exist), the fail callback receives an event argument with an error property, similar to the startChat().fail callback.
chat.restoreChat(options)
.fail(function(event) {
// If there was chat session, but restoration fails, signal failure.
if (event.error) {
alert('chat restoration failed');
return;
}
// If there was no chat session, bind start chat to "start chat" button
jQuery('#myChatButton').on('click', function() {
chat.startChat(startChatOptions);
}
})
.done(function(session) {
// session.sendMessage, session.onAgentConnected and all other method are at your disposal.
});
Some chat states are restored automatically after page reload/navigation. However, most options must be passed to restoreChat directly. Supported options are: