Introduction

Installation

Pick a platform

1. Adding the SDK

You can install the SDK using Swift Package Manager, or Cocoapods.

Add the SDK, unflow-ios-sdk , by using the below URL in your Xcode project, or directly in your Package.swift.

Change the version to the latest, which you can find on our repository.

.package(url: "https://github.com/unflowhq/unflow-ios-sdk", from: .init(1, 10, 0))

2. Configuration

Once you've installed the Unflow SDK for your app, it's time to initialize and configure it.

You should only configure Unflow once, usually early in your application lifecycle. After configuration, the same instance is used throughout your app by accessing the shared singleton in the SDK.

With the UIKit lifecycle, we reccommend initialising Unflow as soon as possible in your AppDelegate, then calling sync when the app enters the foreground.

import UIKit
import UnflowUI

class AppDelegate: NSObject, UIApplicationDelegate {
    var client: UnflowSDK?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        // Initialise the sdk
        client = UnflowSDK.initialize(
            config: UnflowSDK.Config(
                apiKey: "<YOUR API KEY>",
                enableLogging: true
            ),
            analyticsListener: nil
        )

        // Perform our initial sync
        client?.sync()

        return true
    }
    
    // Update when the app comes to the foreground to keep content up to date
    func applicationWillEnterForeground(_ application: UIApplication) {
        client?.sync()
    }
}

API key

Only use your public API key to configure Unflow. You can get your public API key from the app settings on the dashboard.

Enabling logging

Be sure to enable and view debug logs before filing a ticket with Unflow Support.

As detailed in the sample code above, debug logs can be enabled or disabled by setting the enableLogging property when configuring Unflow.

Debug logs will provide detailed log output in the console for what is going on behind the scenes and should be the first thing you check if your app is behaving unexpectedly, and also to confirm there aren't any unhandled warnings or errors.

Production

We log network requests and responses to help with debugging, which can be quite a heavy output. Be sure to disable this in production.


3. Displaying Content

Unflow supports both SwiftUI and UIKit apps. Please find instructions to include the Opener UI for your app below.

All our UI is built nativley with SwiftUI, so for iOS 12 and below users, nothing will show up.

By default we'll render our banner view. This will be scrollable if multiple Screens are live, but full width if only a single Screen exists.

import SwiftUI
import UnflowUI

struct ContentView: View {
    var body: some View {
        OpenerView()   
    }
}

4. Samples

We've built examples of some common use cases in our GitHub repository..

You can find some tutorials here.