Live agent widget for iOS written in swift.
This widget is not just an email type of support widget. The TTLiveAgentWidget shows knowledgebase articles to users, so they can quickly find a solution for their issue. It works with any live agent server with API version 1.
For better performance and security we recommend to use a proxy server. See our proxy server TTLiveAgentWidget-ProxyServer.
- Requires iOS 8.0+
Manually drop content of Pod folder in your project.
Or via CocoaPods:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'TTLiveAgentWidget'
First thing is to import the widget.
// Swift
import TTLiveAgentWidget
// Objective-C
#import "TTLiveAgentWidget-Swift.h"
Before you start using widget you have to configure it. At least you have to set API URL, live agent folder ID where the knowledgebase articles will be obtained, knwledgebase topics and support email. The basic configuration looks like:
let liveAgentWidget = TTLiveAgentWidget.getInstance()
liveAgentWidget.apiURL = "http://liveagent.server"
liveAgentWidget.apiKey = "123456"
liveAgentWidget.apiFolderId = 10
liveAgentWidget.supportEmail = "[email protected]"
// Set topics
supportWidget.topics = [
SupportTopic(key: "ios-general", title: "General issue"),
SupportTopic(key: "ios-problem", title: "Something is not working")
]
Best place to config widget is AppDelegate's didFinishLaunchingWithOptions. There you should also load new articles from server. So it looks like:
let liveAgentWidget = TTLiveAgentWidget.getInstance()
liveAgentWidget.apiURL = "http://liveagent.server"
liveAgentWidget.apiKey = "123456"
liveAgentWidget.folderId = 10
liveAgentWidget.supportEmail = "[email protected]"
// Set topics
supportWidget.topics = [
SupportTopic(key: "ios-general", title: "General issue"),
SupportTopic(key: "ios-problem", title: "Something is not working")
]
liveAgentWidget.updateArticles(nil, onError: nil)
Then usage of the widget is simple as:
// Get Support widget instance
var supportWidget = TTLiveAgentWidget.getInstance()
// Open widget
supportWidget.open(fromController: self, style: .Push)
On TTLiveAgentWidget you can edit following attributes:
topics- topics of knowledgebase articlesmaxArticlesCount- max articles in topicsupportEmail- support email addresssupportEmailSubject- subject for support emailsupportEmailFooter- Dictionary of parameters for email footerapiURL- live agent server urlapiKey- live agent api key (you should use proxy server to hide your api key)apiFolderId- live agent folder id with knowledgebase articlesapiLimitArticles- limit articles from live agent api
If you use TTLiveAgentWidgetStyle.Present style (not recommended for TTLiveAgentWidgetStyle.Push), you can also configure navigation bar look by these attributes:
tintColor- navigation bar tint colornavigationBarCollor- navigation bar background colortitleColor- navigation bar title colorstatusBarStyle- status bar style (UIBarStyle)
Open widget from controller with style. Style can be either TTLiveAgentWidgetStyle.Present (widget will be presented) or TTLiveAgentWidgetStyle.Push (widget will be pushed in navigation controller). If controller is not embedded in UINavigationController you should use TTLiveAgentWidgetStyle.Present. If widget has no articles, then widget open email window directly.
Open knowledgebase articles directly. If keyword is not contained in widget's topics then widget will be opened same way as with open(fromController controller: UIViewController, style: Int).
Asynchronously download articles from live agent. You can handle success or error states.
Opens widget's email composer. Topic is added to email's footer.