🎉 1Flow is proudly backed by Y Combinator.

Get started

You can install 1Flow Library by using CocoaPods. 1Flow currently supports iOS 11.0 and above.

1. Install 1Flow

Install via CocoaPods

1Flow is available through CocoaPods.
  1. If this is your first time using CocoaPods, Install CocoaPods using gem install cocoapods. Otherwise, continue to Step 3.
  1. Run pod setup to create a local CocoaPods spec mirror.
  1. Create a Podfile in your Xcode project directory by running pod init in your terminal, edit the Podfile generated, and add the following line: pod '1Flow'.
  1. Run pod install in your Xcode project directory. CocoaPods should download and install the 1Flow library, and create a new Xcode workspace. Open up this workspace in Xcode or type open *.xcworkspace in your terminal.

Install via Swift Package Manager

1Flow is also available through Swift Package Manager 
  1. In Xcode, select File > Swift Packages > Add Package Dependency.
  1. Follow the prompt and add https://github.com/1Flow-Inc/1flow-ios-sdk github URL.

2. Initialize 1Flow

Import 1Flow into AppDelegate.swift, and initialize 1Flow within application:didFinishLaunchingWithOptions:
import _1Flow; class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. OneFlow.configure("1flow_project_key")
You will need to replace 1flow_project_key with your project key, which you can get from the 1Flow dashboard / Settings → Project Settings: API keys section

3. Log user (optional)

If your app or website does not need the user to sign in, then you can skip to step 4 - Log events.
If your app requires the user to register an account and sign in, you can call a method to bind the user with 1Flow. This way, you'll be able to connect the data with your internal records.
Whenever the user has signed in, you can call OneFlow.logUser() to pass the user identifier, along with any other parameters you'd like to store with us (such as email, full name, etc.), to 1Flow.
// User as signed in.. // First you can create a dictionary that contains any information you want to pass to us let userDetails = ["firstName": "steve", "lastName": "jobs", "number": 123456] as [String : Any] // Call logUser method to bind user with us OneFlow.logUser("uniq_id", userDetails: userDetails)
The userDetails dictionary is optional, so you can just pass in nil if no additional info to send.

4. Track events

Events are central to 1Flow. An Event is a marker in the code to track a key moment in the user flow - like when the user just created an account, completed some action, made a purchase or rejected an offer. We recommend you track at least 4-5 events to better understand the user journey.
let params = ["param1": "value1", "param2": "value2"] OneFlow.recordEventName("event_name", parameters: params)
Here, parameters is optional. pass nil if you don't want any parameters to send with the event.
Advanced tip: Events can be used to trigger surveys, and if you pass in relevant info about the user action (such as the id of the content they just consumed, name of the offer just shown to them, etc.), then you can enrich the survey response with valuable context using our webhooks.
Notes: Parameters in Log User and Track Events will support the Dictionary of these Data Types: String, Int, Double, Float, URL, and Date. If you are converting Date to String, We recommend using a timestamp or Date object. It will be more helpful to set up trigger rules for this parameter across all platforms on 1Flow Dashboard. Parameters other than these types will be skipped.

5. Check for success

Build and run your application. Go to 1Flow dashboard - if the implementation is successful, then this banner should disappear when we receive data from your device:
Image without caption

Show your first survey

Now that you've successfully integrated 1Flow into your app, it's time to create your first survey.
If you've already created a survey and published it (survey shows up in the "In Progress" section of the dashboard), run the app and trigger the event to happen, you should see the survey show up when the event is fired.
To get survey finish callback, Please follow this link