NAV Navbar
java
  • Introduction
  • Getting started
  • Installation
  • Initialization
  • Users
  • Conversion data
  • Introduction

    Welcome on the Omnisense Android SDK Documentation v1.0. You can use these to retrieve and add informations on your Omnisense instance.

    Omnisense is an omnicanal CRM.

    With Omnisense, you can manage the entire lifecycle of your users : Acquisition, Segmentation, Reengagement.

    Acquisition : Omnisense is connected to the main advertising companies of the market and will allow you to manage your acquisition easily.

    Segmentation : Retrieve all your user data within a clear and intuitive interface and segment them in a few clicks.

    Reengagement : Push, mails, sms ... You can reengage your users with all possible and unimaginable means...

    Getting started

    Before installing Omnisense, you should follow this link which explain how to integrate GCM inside your app : Google Cloud Messaging

    Adding Omnisense to your project

    Installation

    settings.gradle

      // settings.gradle
      include ':app', ':omnisense' //Append :omnisense to the list of included modules
    

    Project level build.gradle

      // (top-level) build.gradle
      dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
      }
    

    App level build.gradle

      // (app-level) build.gradle
      dependencies {
        ...
        compile project(':omnisense')
        ...
      }
    
      // Add at the bottom of the file
      apply plugin: 'com.google.gms.google-services'
    

    In AndroidManifest.xml (Replace "yourpackage" by your app's package) Replace omnisense_api_key and omnisense_instance values according to your credentials.

    The omnisense_instance is the beginning of your Omnisense instance URL. Example: If instance's URL is "myinstance.app.omnisense.io" then omnisense_instance = myinstance.

      <permission
            android:name="yourpackage.permission.C2D_MESSAGE"
            android:protectionLevel="signature" />
      <uses-permission android:name="yourpackage.permission.C2D_MESSAGE" />
    
      <application ...>
         <meta-data android:name="omnisense_api_key" android:value="your_api_key" />
         <meta-data android:name="gcm_sender_id" android:value="@string/gcm_defaultSenderId" />
         <meta-data android:name="omnisense_instance" android:value="YOUR_INSTANCE" />
    
         <receiver
          android:name="com.google.android.gms.gcm.GcmReceiver"
          android:exported="true"
          android:permission="com.google.android.c2dm.permission.SEND">
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    
              <category android:name="yourpackage" />
          </intent-filter>
         </receiver>
    
         <service
          android:name="io.omnisense.OmnisenseIntentService"
          android:exported="false">
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
          </intent-filter>
         </service>
      </application>
    

    Updating your project to include Omnisense is easy but requires you to put some modifications in your settings.gradle, build.gradle at the project level and your build gradle at the app level. You'll find more informations to follow in the right part of your screen.

    Initialization

    Application

    Minimal initialization

    public class App extends Application {
      ...
    
      public void onCreate() {
        super.onCreate();
    
        //Must be called before anything else
    
        Omnisense.createInstance(this);
        Omnisense.getInstance().initialize();
      }
    
      ...
    
    }
    

    If you want to user the push functionnality provided by Omnisense, you must follow theses steps

    public class App extends Application {
      ...
    
      public void onCreate() {
        super.onCreate();
    
        //Must be called before anything else
    
        Omnisense.createInstance(this);
        Omnisense.getInstance().getNotificationConfig().setAutoCancel(true);
        Omnisense.getInstance().getNotificationConfig().setPushListener(new PushReceptionListener() {
          @Override
          public void onPushReceived(JSONObject extras) {
            /*
            This is a basic config. The extras object contains the params sent by Omnisense.
            If the extras already contains "u" param, then a deep linking is already present in the extras. Otherwise, you can create your own deep linking according to the provided param then add it to the "u" param. */
            Omnisense.getInstance().getNotificationConfig().setIcon(R.drawable.bike_white);
            Omnisense.getInstance().getNotificationConfig().setClickActivityClass(MainActivity.class);
          }
    
          @Override
          public void onNotificationDisplayed() {
    
          }
        });
    
        Omnisense.getInstance().initialize(); //Must be called before anything else
      }
    
      ...
    
    }
    

    The Omnisense SDK is now successfully included in your project.

    Now you must create an App class extending Application at the root of your app.

    Activities

    BaseActivity

    public class BaseActivity extends Activity {
    
      @Override
      public void onStart()
      {
        super.onStart();
        Omnisense.getInstance().onStart(this);
      }
    
      @Override
      public void onStop()
      {
        super.onStop();
        Omnisense.getInstance().onStop(this);
      }
    
    }
    

    Then in every Activities you just need to extends BaseActivity and everything will be set using the hierarchy

    public class AnyActivity extends BaseActivity {
    
      ...
    
    }
    

    The next point is to add the Omnisense SDK in every activities you need or want. This part is very easy and requires a bit of code.

    We recommand you to create a BaseActivity class extending Activity. That will make you win a lot of time with a very little amount of code.

    Users

    Post Informations

      OmnisenseUser user = Omnisense.getInstance().getCurrentUser();
      user.email = "john.doe@gmail.com";
      user.fb_id = "12143534535646";
      user.firstName = "John";
      user.lastName = "Doe";
      Omnisense.getInstance().saveUser();
    

    To identify the user on Omnisense (after login or sign up), simply update the fields on the OmnisenseUser provided by the instance.

    If you want to add or update some of the user attributes, you can get the current user with the method getCurrentUser and change the values. You will have to call the saveUser after settings the values in order to save them to Omnisense.

    After a log out, simply call the resetCurrentUser to remove the current user.

    User Hash

    Parameter Value Description
    email String
    fb_id String
    first_name String
    last_name String
    birthday Date
    phone String
    address String
    city String
    postal_code String
    country String must be the iso code for country (ISO 3166)
    lang String must be the iso code for lang (ISO 639)
    sex String One of "male", "female"
    optin Boolean Set to true if the user is optin to receive email
    optin_sms Boolean Set to true if the user is optin to receive SMS
    registered Boolean Set to true if the user has signed up to your website
    custom_event_date Date
    company String

    Tracking

    User event tracking Let's say the user is looking a product. When the page is loaded you could do something like that to track your user for looking a product.

    Segment segment = new Segment();
    segment.put("product_name", "The best product ever");
    segment.put("category", "New stuff");
    Omnisense.getInstance().recordEvent("product_view", segment);
    

    To record an event made by the user in the app, call the record event method with segmentation.

    Method Informations

    Function name: recordEvent(identifier: String, segments: Hash)

    Method Parameters

    Parameter Value Description
    identifier String The action name
    segments Hash Set of key/values describing the event ()

    Conversion data

    public class App extends Application {
      ...
    
      public void onCreate() {
        super.onCreate();
    
        //Must be called before anything else
    
        Omnisense.createInstance(this);
    
        Omnisense.getInstance().setTrackingListener(new OnOmnisenseFingerprintListener() {
          @Override
          public void onOmnisenseFingerprintCompleted(Map<String, String> map) {
            // you code here
          }
        };
    
        Omnisense.getInstance().initialize();
      }
    
      ...
    
    }
    

    In case you want to use Omnisense conversion data at first launch in your app, you can use the following method before initialize() method in your App.java file.