Agents can share files with visitors. By default, when a visitor clicks the Download button, the download of the file the agent selected begins.
It is possible to overwrite this behavior using a JavaScript API. As an example, this can be used to manipulate the default behavior to:
- Present the visitor with a Save-process, so they can choose where to save a document;
- Embed a file viewer, so a document is presented to the visitor immediately.
To change the default behavior, implement the filetransfer JavaScript reference, and implement the openUrl function on any and all pages on which a visitor may receive files on your Live Assist Engagement
Javascript API
The eventData object is JSON which can be parsed to retrieve the download URL.
Example Implementation
The following is a most basic implementation of the File Transfer API. In this example, the user is presented with an alert-popup to present them with the URL of the File to download.
When the visitor clicks the Download button, the following alert is displayed:
Android
If your application uses the Live Assist Android SDK, when a visitor clicks Download the application prompts the Android Download Manager to transfer the file to the default storage location. The user may be prompted for permission to save the file.
It is possible to override the default implementation to allow the Android application to manage the visitor's experience.
In the Android Application apply the following changes:
- import FileTransferObservable
import com.cafex.liveassist.FileTransferObservable;
- Create an Instance of the FileTransferObservable Object
FileTransferObservable fileTransferObservable = FileTransferObservable.getInstance();
- Add an Observer
Observer fileTransferObserver = new Observer() {
@Override public void update(Observable observable, Object o) {
Log.d("FileTransferExample","File URL:" + o);
}
};
iOS
If your application uses the Live Assist iOS SDK, when a visitor clicks Download the application attempts to load the file in a suitable application. If none is found, the URL is loaded in the Safari browser. Images and most documents render here, or prompt the user to download the file.
It is possible to override the default implementation to allow the iOS application to manage the visitor's experience.
In the iOS Application apply the following changes:
- Create and instance of FileTransferObservable
FileTransferObservable *fileTransferObservable = [FileTransferObservable sharedInstance];
- Create an Observer
[fileTransferObservable addObserver:^(NSNotification * _Nonnull note) { // ADD YOUR CODE HERE... }];