Latest 2.0.7
Homepage https://github.com/livechat/chatio-chat-widget-ios
License MIT
Platforms ios 9.0
Frameworks UIKit, WebKit
Authors

Introduction

chat.io for iOS allows you to integrate chat.io into your iOS app.

Carthage compatible
Version
License
Platform

Requirements

  • iOS 9.0+
  • Xcode 8.0+

Installation

CocoaPods

If you use CocoaPods to manage your dependencies, simply add chatio to your Podfile.

pod 'chatio', '~> 2.0.7'

Manual Installation

You can integrate iOS chat widget into your project manually without using a dependency manager.

Swift

Just drag all files from the Sources directory into your project.

Objective-C

Drag all files from the Sources directory into your project. When adding first *.swift file to Objective-C project, Xcode will ask you to create a Bridging Header. It is not necessary for chat widget to work, so you can decline unless you plan to call Swift code from Objective-C. More information about bridging headers and Swift and Objective-C interoperability can be found here. You need to put following import statement: #import "<Your Project Name>-Swift.h" at the top of your .m file.

Also, for Objective-C projects, you need to set the Embedded Content Contains Swift Code flag in your project to Yes (found under Build Options in the Build Settings tab).

Usage

Initalization

import chatio

Chatio.licenseId = "YOUR_LICENSE_ID"

Presenting Chat Widget

Chatio.presentChat()

Setting Custom Variables

You can provide customer name or email if they are known, so customer will not need to fill pre-chat survey:

Chatio.name = "iOS Widget Example"
Chatio.email = "[email protected]"

If you want to associate some additional info with your customer, you can set Custom Variables:

Chatio.setVariable(withKey:"Variable name", value:"Some value")

Assign chat to specific group

You can route your customers to specific group of agents by providing groupId. More information can be found here: https://www.livechatinc.com/kb/dividing-live-chat-by-group/.

Chatio.groupId = "7"

Notifying user about agent response

You can notifiy your user about agent response if chat was minimized by the user. To handle incoming messages your class must implement ChatioDelegate protocol and set itself as Chatio.delegate.

class YOUR_CLASS_NAME : ChatioDelegate { // Your class need to implement ChatioDelegate protocol
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Chatio.licenseId = "YOUR_LICENSE_ID"
        Chatio.delegate = self // Set self as delegate

        return true
    }

    func received(message: ChatioMessage) {
        print("Received message: (message.text)")
        // Handle message here
    }
}

Handling URL

By default, all links in chat messages are opened in Safari browser. To change this behavior you can use the ChatioDelegate to handle URL’s yourself.

func handle(URL: URL) {
    print("URL is (URL.absoluteString)")
    // Handle URL here
}

Sending Photos from device library

If you have file sharing enabled for visitors, you should provide usage description by including NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description) key in your Info.plist file to avoid crash on iOS 10 or higher.

Example Apps

Example apps can be found in the Examples folder. Samples for both Swift and Objective-C are provided.

Getting help

Any questions? Chat with Us!

License

iOS chat widget is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "chatio",
    "version": "2.0.7",
    "summary": "chat.io chat window for your iOS app.",
    "homepage": "https://github.com/livechat/chatio-chat-widget-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u0141ukasz Jerciu0144ski": "[email protected]"
    },
    "source": {
        "git": "https://github.com/livechat/chatio-chat-widget-ios.git",
        "tag": "2.0.7"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Sources/*.{swift}",
    "resources": "Sources/*.{js}",
    "frameworks": [
        "UIKit",
        "WebKit"
    ],
    "xcconfig": {
        "SWIFT_VERSION": "4.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This