iOS – Objective-C

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.m, and initialize 1Flow within application:didFinishLaunchingWithOptions:
@import _1Flow; @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application [OneFlow configure:@"your-project-api-key"];
Note: you need to replace your-project-api-key with your actual project API key. Click here and navigate to Settings → Project → API keys section. Copy your API key and paste it into the code snippet.

Customize font (optional)

If you’re using custom fonts in your app, you can configure 1Flow to use the same font as the rest of your app.
[OneFlow useFontWithFontFamily:@"Courier New"];
fontFamily is optional. you can pass nil if you want to restore it to default system font.

Setup Observer (optional)

You can setup observer to listen for OneFlow setup event. Use OneFlow.observer = self; before configuration call.
Now you can extend you class as below:
- (void)oneFlowSetupDidFinish { } - (void)oneFlowSetupDidFail { }
There is one more property isSetupCompleted which can be use to determine if OneFlow finished setup or not. You can use check this like OneFlow.isSetupCompleted and proceed further.

Disable logs (optional)

You can disable the logs printed by OneFlow in your console. Use [OneFlow shouldPrintLog:NO]; to keep your console clean from OneFlow logs.

3. Identify users

In every new session, 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.
To identify a user:
// User as signed in.. // First you can create a dictionary that contains any information you want to pass to us NSDictionary *userDetails = @{@"firstName": @"steve", @"lastName":@"jobs", @"number": @123456}; // 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.
To track an event:
NSDictionary *parameters = @{@"param1": @"value1", @"param2": @"value2"}; [OneFlow recordEventName:@"event_name" parameters:parameters];
Here, parameters is optional. pass nil if you don't want any parameters to send with the event.
Parameters in Identify and Track calls support the following types: String, Int, Double, Float, URL, and Date.

Unsupported data types will be ignored.
Parameters in Identify and Track calls support the following types: String, Int, Double, Float, URL, and Date. Unsupported data types will be ignored.

5. Announcement Inbox

To display the announcements inbox to the user, invoke the function [OneFlow showInbox];. This action will render the announcements inbox at the top of the screen.
Note: Until the Announcement inbox screen is presented, the system will bypass any surveys or in-app announcements associated with events triggered within that timeframe.

Launch your first survey

Now that you've successfully installed 1Flow into your app, it's time to create your first survey.
If you've already created a survey and published it, run the app and trigger the event. You should see the survey show up when the event is fired.