LabibaBotClient
Swift Library to add Labiba chat bot to your iOS application
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- Xcode 8.0+
- iOS 9.0+
- Swift 3.3
Installation
LabibaBotClient is available through CocoaPods. To install it, simply add the following line to your Podfile:
platform :ios, '9.0'
source 'https://{YOUR_BITBUCKET_USERNAME}@bitbucket.org/imaginejo/specs.git'
source 'https://github.com/CocoaPods/Specs.git'
target 'YOUR_APP_TARGET' do
use_frameworks!
# Pods for YOUR_APP_TARGET
pod 'LabibaBotClient'
end
OR
You can first clone this repo into some folder Ex. "path/to/yourworkspace".
cd path/to/yourworkspace
git clone https://{YOUR_USER_NAME}@bitbucket.org/imaginejo/labibabotclient_ios.git
Then, simply add the following line to your Podfile:
use_frameworks!
platform :ios, '9.0'
target 'YOUR_APP_TARGET' do
pod 'LabibaBotClient', :path => 'path/to/yourworkspace/labibabotclient_ios'
end
Usage
Configuration
Before presenting Labiba chat screen, you must first configure and customize it. You should do this as early as the app launches. In your AppDelegate.swift
add the following lines:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Labiba.initialize(pageId: "310363199529584", botName: "bot-name".local)
Labiba.setSenderId( "1764343183643935")
Labiba.setBotAvatar( #imageLiteral(resourceName: "imagine_logo"))
Labiba.setTintColor( #colorLiteral(red: 0.2501407726, green: 0.6199833439, blue: 0.4300507522, alpha: 1))
// Labiba.setBasePath( ... ) //In case, you need it
// Labiba.setUserAvatar( ... )
return true
}
-
pageId
: Can be obtained when you setup iOS channel in Labiba management system. -
Labiba.setSenderId(_ senderId:String)
: You should call this at some point in you application before launching chat screen, and it must be unique per app user. A possible use case is to generate this by your back-end application then hand it to your app to be used for Labiba, this way you can allow for better integration between your system and Labiba chat bot system.
Launching the bot
Movable Alias:
By which user tap on it to launch the conversation, see below:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Labiba.showMovableAlias(corner: .bottomRight, animated: true)
}
Conversation UIViewController:
You can put this where ever you like (Navigation Controller, TabBar Controller, ...etc) , just use the following method to create it:
Labiba.createConversation()
WARNING
You must call Labiba.setSenderId( _ senderId:String )
method at some point in your application before launching Labiba chat bot by any way. Refer to Configuration section.
Author
Suhayb Al-Absi, [email protected]
License
All copyrights are reserved to Labiba.ai, 2018.