flutter_1flow_sdk 1.0.8 copy "flutter_1flow_sdk: ^1.0.8" to clipboard
flutter_1flow_sdk: ^1.0.8 copied to clipboard

outdated

1Flow flutter SDK.

About 1Flow #

1Flow is tool for Analytics and Getting Feedback from your users. 1Flow is very easy to integrate and use in your project. Read More from 1Flow Dashboard

Get started #

Here you will know how to set up 1Flow library on Flutter cross-platform apps. Setting up 1Flow for your Flutter app is easy and you can do it by following steps.

Prerequisites #

  • Flutter SDK
  • For Android:
    • A device or emulator with Google Play services installed and up-to-date.
    • Android Studio.
  • For iOS:
    • XCode
    • An iOS device such as an iPhone or an iPad

1. Add the SDK #

Create your Flutter application if you haven't already, see the Flutter guide and setup it by following given instructions.

Open pubspec.yaml and add the following dependencies::

dependencies:
  flutter_1flow_sdk: ^1.0.8

Open a Terminal window in your flutter project directory and type:

flutter pub get

2. Setup #

For iOS #

  • Navigate to ios directory and install pods

    cd ios
    pod install
    

For Android #

  • Include below repository to your project's build.gradle file:

    allprojects{ 
    	repositories{ 
    		google() 
    		jcenter() 
    		maven{url 'https://jitpack.io'} 
    	} 
    }
    
  • Add dependency to your app's build.gradle file:

    defaultConfig { 
    	.... 
    	minSdkVersion 21 
    } 
    dependencies { 
    	....
    	implementation "com.github.1Flow-Inc:1flow-android-sdk:0.6.31" 
    }
    

3. Configure #

Open your Flutter Application’s lib/main.dart and write following code in main()

	// Add this line to import 1Flow at the top of the file
	import 'package:flutter_1flow_sdk/flutter_1flow_sdk.dart';
	
	void main() {
		runApp(MyApp());
	    // Add this line to configure 1Flow
	    OneFlow.configure('<1flow_project_key>',true); // true if want to enable surveys otherwise false.
	}

You will need to replace 1flow_project_key with your own key, which you can get from 1Flow dashboard / Settings → Project Settings: API keys section.

4. Log user (optional) #

If your app or website does not need user to sign in, then you can skip to step 4 - Log events.

If your app requires 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, to 1Flow.

	// import 1Flow SDK 
	import 'package:flutter_1flow_sdk/flutter_1flow_sdk.dart';

	// Call logUser method to bind user with us 
	try {
	    OneFlow.logUser('custom', { 'product': 'test', 'price': 123.9 });
	} on PlatformException {
	    print('logUser: error occured');
	}

The userDetails dictionary is optional, so you can just pass in nil if no additional info to send.

5. 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 user just created an account, completed some action, made a purchase or rejected an offer. We recommend you track at least 4-5 events in order to better understand the user journey.

	// import 1Flow SDK 
	import 'package:flutter_1flow_sdk/flutter_1flow_sdk.dart';
	
	try {
	    OneFlow.recordEventName('custom', { 'product': 'test', 'price': 123.9 });
	} on PlatformException {
	    print('recordEventName: error occured');
	}

Here, parameters is optional. pass null if you don't want any parameters to send with 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.

6. 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 "In Progress" section of dashboard), run the app and trigger the event to happen, you should see the survey show up when the event is fired.

Note: If your app or website does not need user to sign in, then you can skip to step 4 - Log events.