🎉 1Flow is proudly backed by Y Combinator.
logo

Get Started

We'll show you how to install the 1Flow Android library using Gradle.

1. Install 1Flow

Install via Gradle

a) If gradle version is 6.5 or lower, include the below repository in your project's build.gradle file:
java
allprojects{ repositories{ google() jcenter() maven{url 'https://jitpack.io'} } }
If gradle version is higher than 6.5, add the below code in settings.gradle.
java
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven{url 'https://jitpack.io'} } }
b) Add dependency in your app's build.gradle file:
java
defaultConfig { .... minSdkVersion 21 } dependencies { .... implementation "com.github.1Flow-Inc:1flow-android-sdk:2022.10.01" }

2. Initialize 1Flow

a) Call this method from onCreate in Main Activity / Launcher Activity.
java
private void configureOneFlow(){ OneFlow.configure(this@YourActivityName, "your-project-api-key"); }
💡
Note: you need to replace 'your-project-api-key' with your actual project API key. Click here and navigate to Project Settings → API keys section.
b) After adding the above method, you will require to import 'OneFlow' in the respective class.

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.
java
val userDetail: HashMap<String, Any?> = HashMap() userDetail.put("name","TestUser") userDetail.put("age", 79) userDetail.put("height",5.10) // Calling this method will bind user with 1Flow OneFlow.logUser("userIdentifier", userDetail);
The 'userDetail' HashMap is optional, so you can just pass in null 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.
java
val mapValues: HashMap<String, Any?> = HashMap() mapValue.put("testKey1","testValue") mapValue.put("testKey2","testValue") mapValue.put("testKey3","testValue") OneFlow.recordEvents(event_name, mapValues);// event_name should be String
Here, 'mapValue' is optional. Pass null if you don't want any additional 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.

Common issues and fixes

Manifest merging issue
Duplicate class android.support.v4.app.INotificationSideChannel
Pro-guard issue (things working in debug mode but not in release mode).

Helpful?