Swiftpack.co - Forethought-Technologies/solve-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Forethought-Technologies.
Forethought-Technologies/solve-ios 2.1.2
Contains the public XCframework
⭐️ 2
🕓 10 hours ago
.package(url: "https://github.com/Forethought-Technologies/solve-ios.git", from: "2.1.2")

Forethought - Solve iOS SDK

This repository contains the framework and instructions for the Forethought iOS SDK.

A valid API key is needed in order to use the Forethought Solve SDK. In additon to the documentation below, sample apps have been written in Objective-C & Swift, as well as a SwiftUI implementation


Swift Package Manager

  1. In Xcode, File > Add Packages.

  2. Enter the Forethought iOS GitHub repo URL (https://github.com/Forethought-Technologies/solve-ios)

  3. Tap Add Package. Follow the remaining prompts and Xcode will automatically download the framework


  1. Forethought is also available through CocoaPods.

  2. In the Podfile, add the following line:

    pod 'Forethought'
  3. Run the following command:

    $ pod install
  4. Make sure to use the .xcworkspace file and NOT the .xcodeproj from now on.

Basic Usage

  1. In AppDelegate.swift file, replace __YOUR_KEY_HERE__ with a valid Forethought API key:
    ForethoughtSDK.start(apiKey: "__YOUR_KEY_HERE__")
  2. Open the Forethought widget:
    import 'Forethought'

Other ways to open

SwiftUI View

Returns a SwiftUI view


Use of a Navigation Controller Directly

Attach the Forethought SDK directly onto a navigation stack:

@IBAction func contactSupportTapped() {
    ForethoughtSDK.show(fromNavigationController: self.navigationController)

Optional Additions

Workflow Context Variables

Pass in Workflow Context Variables that have been defined via the Forethought Dashboard. (Note: you do not need to prefix with data-ft)

ForethoughtSDK.dataParameters = ["language":"EN", "user-email": "[email protected]", "workflow-context-variable": "value"]

Widget Configuration Parameters

Current configuration parameters are all the config-ft prefixed parameters under Additional Attributes. (Note: you do not need to prefix with config-ft)

ForethoughtSDK.configParameters = ["theme-color": "#7b33fb"]

Handoff Methods

To handoff customers from Forethought to an Agent Chat Provider like Kustomer:

  1. Set a delegate to the Forethought SDK. Do this before presenting the screen:
    ForethoughtSDK.delegate = self
  2. Make sure the object conforms to the ForethoughtDelegate protocol
    class ViewController: UIViewController, ForethoughtDelegate {
  3. Conform to ForethoughtDelegate by adding the following method
    func startChatRequested(handoffData: ForethoughtHandoffData) {}
  4. Add handoff implementation here. For example.
  5. When the handoff is complete, sendHandoffResponse will continue the Forethought conversation and update the conversation context as successfully passed off to an Agent Chat Provider or not.
    ForethoughtSDK.sendHandoffResponse(success: true)

Handoff Example

func startChatRequested(handoffData: ForethoughtHandoffData) {
    print("Chat Requested: \(handoffData)")

    // close forethought widget
    ForethoughtSDK.hide(animated: false)

    // start a Kustomer chat
    Kustomer.startNewConversation(initialMessage: KUSInitialMessage(body: handoffData.question, direction: .user))

    // if handoff was successful
    ForethoughtSDK.sendHandoffResponse(success: true)

    // if handoff was unsuccessful
    ForethoughtSDK.sendHandoffResponse(success: false)

widgetClosed delegate

Called when the customer presses the close widget icon. Make sure to call ForethoughtSDK.hide if you choose to implement this.

func widgetClosed() {
    // do something
    // call hide to dismiss the widget
    ForethoughtSDK.hide(animated: true) {
        // do something on completion


⛔️ Plugins are deprecated in starting in version 2.0.0 ⛔️


Documentation has been provided as a .doccarchive to enable full documentation directly inside Xcode. To use, simply double-click on Forethought.doccarchive, and Xcode will handle the rest.


Stars: 2
Last commit: 19 hours ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1 week ago

widgetClosed delegate

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics