This library provides Webim SDK for iOS – a way to integrate Webim service into your iOS app.
Minimum iOS version supported – 8.0.
Add following line for your target in your Podfile:
pod 'WebimClientLibrary', :git => 'https://github.com/webim/webim-client-sdk-ios.git', :tag => '3.37.0'
use_frameworks! must be specified.
Add following line to your Cartfile:
github "webim/webim-client-sdk-ios" ~> 3.37.0
https://github.com/webim/webim-client-sdk-iosin the "Choose Package Repository" dialog.
Trying to integrate WebimClientLibrary into your Objective-C code? Try out our WebimClientLibraryWrapper.
Previous Objective-C version (version numbers 2.x.x) can be reached from version2 branch.
If you don't have CocoaPods installed you should firstly run
sudo gem install cocoapods.
To run the example project, clone the repo and run
pod install from the Example directory first.
SDK functionality usage starts with session object creating.
Webim class method
newSessionBuilder() returns session builder object (class
SessionBuilder) (both of this classes and their methods are described inside Webim.swift file). Then setting session parameters methods are to be called on the created
SessionBuilder object. After all necessary parameters are set, method
build() is to be called. This method returns
Typical usage example:
let webimSession = try Webim.newSessionBuilder().set(accountName: "ACCOUNT_NAME").set(location: "LOCATION_NAME").build()
All parameters that can be set while creating a session and all errors that can be thrown are also described in Webim.swift file. Account name and locations are the only required of them.
After the session is created it must be started by
resume() method (since a session object is initially paused).
Session can be paused (
pause() method) and resumed (
resume() method) as well as destroyed (
destroy() method) if necessary. All of this methods are described in WebimSession.swift file.
All message stream methods are described in MessageStream.swift file.
For this methods usage ability the
MessageStream object is have to be getted through
getStream() method by
WebimSession class object.
send(message:) – send message,
rateOperatorWith(id:byRating:) – rate operator,
closeChat() – close chat.
newMessageTracker(messageListener:) method by
MessageStream object creates
MessageTracker object, which can be used to control a message stream inside an app.
getNextMessages(byLimit:completion:) method requests a certain amount of messages from the history.
Methods descriptions can be found inside MessageTracker.swift file.
MessageListener protocol describes methods which can help to track changes in the message stream. An app must have a class which implements this protocol methods:
changed(message:to:). This methods are called automatically when new message is added, a message is deleted, all messages are deleted and a message is changed respectively.
Full methods descriptions can be found inside MessageListener.swift file.
MessageListener protocol methods operate on
Message objects which is described inside Message.swift file.
All necessary information about specific message can be getted through
Message objects methods: unique message number (
getID() method), message text (
getText() method), attached file info (
getAttachment() method) etc.
All related tools (methods for working with attachments, message types etc.) are also described in Message.swift file.
Methods for getting information about specific operator are described inside Operator.swift file. Operator object can be getted through
Methods for working with remote notifications by Webim service are described inside WebimRemoteNotification.swift file.
Specific remote notification object can be getted through
parse(remoteNotification:) method. This class also has method
isWebim(remoteNotification:) which can be used to easily discover whether the notification is send by Webim service or not.
FatalErrorHandler protocol description. Its methods can be implemented by an app for tracking errors which can arise in progress. All kinds of specific errors are described inside the same file.
MessageStream.swift also contains additional protocols descriptions which can be implemented by an app classes for tracking different particular changes. E.g.
ChatStateListener protocol methods are called when chat state is changed (all the specific chat states are described in the same file).
For remote notifications to be enabled you should send your app certificates/private key to us. For more information please contact to our support!
For iOS to be able to handle remote notifications automatically your app must be aware of possible remote notification types and arguments.
P.CRmeans that operator sent contact information request.
P.OAmeans that operator accepted chat.
P.OFmeans that operator sent a flie.
P.OMmeans that operator sent a text message.
P.WMmeans that operator sent a widget message (for this functionality support one should contact Webim support).
loc-args values for this types:
P.OA: operator's name.
P.OF: operator's name, file name.
P.OM: operator's name, message text.
Remote notification handling with Strings.localizable file example:
"P.OM" = "Message from %@ is received: %@."
Entities and methods described above are all that it necessary for working in an app with Webim service and even more.
Abilities described In this manual are not all of the existing ones, so after necessary minimum is implemented it is recommended to get acquainted with full list of protocols and methods listed in SDK public files.
All public interfaces, classes and methods are described inside this files (in alphabetical order):
Every single class, protocol, method etc. description provided inside documentation.
WebimClientLibrary uses SQLite.swift. (There's no need to add this depencies into Podfile.)
In the sake of ease of several functionalities implementation Example app uses (in alphabetical order):
WebimClientLibrary is available under the MIT license. See the LICENSE file for more info.