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:javaallprojects{ repositories{ google() jcenter() maven{url 'https://jitpack.io'} } }
If gradle version is higher than 6.5, add the below code in settings.gradle.
javadependencyResolutionManagement { 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:javadefaultConfig { .... minSdkVersion 21 } dependencies { .... implementation "com.github.1Flow-Inc:1flow-android-sdk:0.6.42" }
2. Initialize 1Flow
a) Call this method from onCreate in Main Activity / Launcher Activity.
javaprivate void configureOneFlow(){ OneFlow.configure(context, "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.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. javaHashMap<String, Object> userDetail= new HashMap<String, Object>(); userDetail.put("Name", "TestUser"); userDetail.put("Age", 54); 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.
javaHashMap<String, Object> mapValues = new HashMap<String, Object>(); mapValues.put("testKey1", "testValue1"); mapValues.put("testKey2", "testValue2"); mapValues.put("testKey3", "testValue3"); 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:

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
Common issues and fixes
Manifest merging issue
- In Manifest add the below lines
java<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" >
- In <application> tag add the below code
java<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" tools:replace="android:icon,android:roundIcon,android:theme" >
Duplicate class android.support.v4.app.INotificationSideChannel
- In gradle.properties file enable androidx by adding the below lines
javaandroid.useAndroidX=true android.enableJetifier=true