Skip to content

Latest commit

 

History

History
202 lines (133 loc) · 6.9 KB

README.md

File metadata and controls

202 lines (133 loc) · 6.9 KB

CocoaPods Languages Version Carthage compatible GitHub

Infoset

Infoset iOS SDK

Infoset iOS SDK allows you to integrate Infoset Chat with your iOS app.

Requirements

  • iOS 12.0+
  • Xcode 8.0+

Installation

CocoaPods

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

    target :YourTargetName do
      pod 'Infoset'
    end

Carthage

If you use Carthage to manage your dependencies, simply add 'infoset/infoset-ios' to your Cartfile.

  1. Add github "infoset/infoset-ios" to your Cartfile.
  2. Run carthage update.
  3. Go to your Xcode project's "General" settings. Drag Infoset.xcframework from Carthage/Build/iOS to the "Embedded Binaries" section. Make sure “Copy items if needed” is selected and click Finish.

Manual Installation

You can integrate Infoset iOS SDK into your project manually without using a dependency manager.

  1. Download Infoset iOS SDK and extract the zip.
  2. Drag Infoset.xcframework into your project.

Make sure "Copy items if needed" is selected and click Finish.

  1. In the target settings for your app, set the Infoset.xcframework to “Embed & Sign”. This can be found in the “Frameworks, Libraries, and Embedded Content” section of the “General” tab.

  2. Create a new "Run Script Phase" in your app’s target’s "Build Phases" and paste the following snippet in the script text field:

    bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Infoset.xcframework/strip-frameworks.sh"

This step is required to work around an App Store submission bug when archiving universal binaries.

Update Info.plist

If you have file sharing enabled in your Infoset chat widget, you'll need to make sure these entries exist in your Info.plist to avoid crashes on iOS 10 or higher:

  • NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)
  • NSCameraUsageDescription (Privacy - Camera Usage Description)
  • NSMicrophoneUsageDescription (Privacy - Microphone Usage Description)

You can check Info.plist files in example projects.

Usage

Initalization

import Infoset

InfosetChat.apiKey = "YOUR_WIDGET_API_KEY"
InfosetChat.iosKey = "YOUR_WIDGET_IOS_KEY"

Presenting Chat Widget

InfosetChat.presentChat()

Chat widget will be dismissed when the user clicks the dismiss button. You can dismiss it programmatically as well:

InfosetChat.dismissChat()

Using UIWindowSceneDelegate

If your app is using UIWindowScene API you need to perform additional configuration steps in you window scene delegate class.

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        InfosetChat.windowScene = (scene as? UIWindowScene)
    }
}

Setting User Variables

You can provide your user's details such as name and email if they are known, so you will immediately know who you are talking to on the Infoset dashboard:

InfosetChat.visitor = InfosetChatVisitor(id: 123, email: "example@infoset.app", firstName: "John", lastName: "Doe")

All fields are optiona. See the InfosetChatVisitor class for all of the user fields.

Assign chat to tags

You can route your chats to specific tags by providing tags.

InfosetChat.tags = "High Priority"

You can provide multiple tags separated by commas.

InfosetChat.tags = "Support,Recurring Customer"

Notifying the user about the agent's response

You can subscribe to incoming messages and notify the user even if the chat window is minimized. To handle incoming messages, your class must implement InfosetChatDelegate protocol and set itself as InfosetChat.delegate.

class YOUR_CLASS_NAME : InfosetChatDelegate { // Your class need to implement InfosetChatDelegate protocol
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    InfosetChat.apiKey = "YOUR_WIDGET_API_KEY"
    InfosetChat.iosKey = "YOUR_WIDGET_IOS_KEY"
    InfosetChat.delegate = self // Set self as delegate

    return true
  }

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

Handling URLs

By default, all links in chat messages are opened in Safari. To change this behavior you can use the InfosetChatDelegate to handle URLs yourself.

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

Subscribing room events

You can subscribe to room events to be instantly informed about room status changes with roomId parameter. To handle room status changes, your class must implement InfosetChatDelegate protocol and set itself as InfosetChat.delegate.

    func roomOpened(roomId: Int64) {
        // Do sth
    }

    func roomClosed(roomId: Int64) {
        // Do sth
    }

    func roomReopened(roomId: Int64) {
        // Do sth
    }

On-premise support

If you are using on-premise version of Infoset, you should set the InfosetChat.webviewUrl to your on-premise URL.

InfosetChat.webviewUrl = "https://your-on-premise-dashboard-url/chat/open_chat.html"

You can contact us for more information.

Sample Apps

Sample apps for both Swift and Objective-C can be found in the Examples folder.

React Native Support

We have a React Native SDK for React Native / Expo ⚛️

Getting help

If you have any questions or want to provide feedback, shoot an email or chat with us!