Latest 1.0.0
Homepage https://github.com/livechat/livechat-webview-ios
License MIT
Platforms ios 8.0
Frameworks UIKit, WebKit
Authors

LiveChat WebView for iOS

LiveChat WebView for iOS allows you to integrate LiveChat chat window into your iOS app.

Version
License
Platform

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate LiveChat WebView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
pod 'LiveChatWebView', '~> 1.0'
end

Then, run the following command:

$ pod install

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).

Manual Installation

You can integrate LiveChat WebView into your project manually without using a dependency manager.

Swift

Just drag the LiveChatViewController.swift file into your project.

Objective-C

Drag the LiveChatViewController.swift file 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 LiveChat WebView 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 "<Your Project Name>-Swift.h" on 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

LiveChatViewController

A LiveChatViewController is UIViewController subclass responsible for loading and displaying LiveChat Window. LiveChatViewController takes in your license number when initializing.

// Swift
// Initialize LiveChatViewController with your license number:
let livechat = LiveChatViewController(license: "PUT_YOUR_LICENSE_NUMBER_HERE")
// Present LiveChatViewController
navigationController?.pushViewController(livechat, animated: true)
// Objective-C
// On the top of your .m file:
@import LiveChatWebView;

// Initialize LiveChatViewController with your license number:
LiveChatViewController *liveChatViewController = [[LiveChatViewController alloc] initWithLicense:@"PUT_YOUR_LICENSE_NUMBER_HERE"];
// Present LiveChatViewController
[self.navigationController pushViewController:liveChatViewController animated:YES];

Customizing navigation bar title

// Swift
// Initialize LiveChatViewController with your license number:
let livechat = LiveChatViewController(license: "PUT_YOUR_LICENSE_NUMBER_HERE")
// 
livechat.title = "Support"
// Present LiveChatViewController
navigationController?.pushViewController(livechat, animated: true)
// Objective-C
// On the top of your .m file:
@import LiveChatWebView;

// Initialize LiveChatViewController with your license number:
LiveChatViewController *liveChatViewController = [[LiveChatViewController alloc] initWithLicense:@"PUT_YOUR_LICENSE_NUMBER_HERE"];
liveChatViewController.title = @"Support";
// Present LiveChatViewController
[self.navigationController pushViewController:liveChatViewController animated:YES];

LiveChatViewControllerDelegate

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

// Swift
class YOUR_CLASS_NAME : LiveChatViewControllerDelegate { // Your class need to implement LiveChatViewControllerDelegate protocol
func openChat() {
// Initialize LiveChatViewController with your license number:
let livechat = LiveChatViewController(license: "PUT_YOUR_LICENSE_NUMBER_HERE")
livechat.delegate = self // Set self as delegate
navigationController?.pushViewController(livechat, animated: true)
}

func handleURL(URL: NSURL) {
print("URL is (URL.absoluteString)")
// Handle URL here
}
}
// Objective-C
@interface YOUR_CLASS_NAME () <LiveChatViewControllerDelegate> { // Your class need to implement LiveChatViewControllerDelegate protocol

@end

@implementation YOUR_CLASS_NAME
- (void)openChat {
// Initialize LiveChatViewController with your license number:
LiveChatViewController *liveChatViewController = [[LiveChatViewController alloc] initWithLicense:@"PUT_YOUR_LICENSE_NUMBER_HERE"];
livechat.delegate = self // Set self as delegate
[self.navigationController pushViewController:liveChatViewController animated:YES];
}

- (void)handleURL:(NSURL *)URL {
NSLog(@"URL is %@", URL.absoluteString);
// Handle URL here
}
@end

Example Apps

Example apps can be found in the Examples folder.

Getting help

Chat with Us!

License

LiveChatWebView is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "LiveChatWebView",
    "version": "1.0.0",
    "summary": "LiveChat chat window for your iOS app.",
    "homepage": "https://github.com/livechat/livechat-webview-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u0141ukasz Jerciu0144ski": "[email protected]"
    },
    "source": {
        "git": "https://github.com/livechat/livechat-webview-ios.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "LiveChatWebView/Classes/**/*",
    "frameworks": [
        "UIKit",
        "WebKit"
    ]
}

Pin It on Pinterest

Share This