Git Product home page Git Product logo

omniata-android-sdk's Introduction

Omniata-android-sdk

Build to omniata-android-sdk.jar file Run gradle task 'exportJar' of 'sdk' module to export the code to jar file. The file will be in this path: /sdk/release/

Build the module to upload to jcenter, do as follows:

a. modify the 'sdkVersion' number in build.gradle file of 'omniata-android' module

b. build the project and run the following two command in terminal

gradle install
gradle bintrayupload

c. the SDK can be used by including the following line in project's build.gradle file

dependencies {
    compile 'com.omniata.android-library:omniata-android:2.1.6'
}

The file stacks can be checked in this link: https://dl.bintray.com/junomniata/maven/com/omniata/android/library/omniata-android/2.1.6/ And the jcenter link of the SDK is: https://bintray.com/junomniata/maven/omniata-android-library/view

Features and technical description

Omniata Android SDK is a library developed by Omniata that allows Android application developers to easily integrate their applications with Omniata services. The key features of the SDK are sending events to Omniata using Event API and requesting content for users using Channel API.

Release Notes

This version is compatible with the previous version v2.0.0. Changed details: - Change methods name for Unity usage. - Fix Unity related URL encoded bug.

Integrating Omniata Android SDK

Installation and upgrade

The Omniata Android SDK requires the following permissions in your ApplicationManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

And also include the following meta-data tag within 'application' element

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Next place omniata-android-sdk.jar in your project's lib directory. Finally add an import for the SDK. Upgrading to the latest version involves replacing the old jar with the new one.

  • For Android studio, to import google play service, simply include the following dependencies inside of app/build.grandle
dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.google.android.gms:play-services-ads:+'
  compile 'com.android.support:appcompat-v7:23.1.0'
}
  • For Eclipse, import the existing Projects to Workspace, /extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar

Initialization

Import the SDK package.

import com.omniata.android.sdk.*;

Initialize the library by calling the initialize function with the identifier of the user and the API key provided in the panel. For initial testing it is recommended to track events in debug mode against the event monitor. This will allow you to debug your events in real-time. <ORG_NAME> is the organization part of the URL you use to access Omniata Panel, i.e. https://organization.panel.omniata.com -> <ORG_NAME> would be 'organization'

public class MainActivity extends Activity {
  @Override protected void onCreate(Bundle savedInstanceState) {
  ...
   //========================
   // Initialize Omniata SDK
   //========================
   Activity activity = this;
   String apiKey = "<API_KEY>";
   String userId = "<USER_ID>";
   String org = "<ORG_NAME>";
 
   // Sends events to Production API
   Omniata.initialize(activity, apiKey, userId,org);
    
   ...
  }
  ...
}

Tracking Load Event

This should be called whenever the user begins their session.

Omniata.trackLoad();

Tracking Revenue Event

double total = 1.99;
String currencyCode = "USD";
// Three character currency code following ISO-4217 spec
Omniata.trackRevenue(total, currencyCode);

Tracking Custom Event

import org.json.JSONObject;
import org.json.JSONException;
...
JSONObject parameters = new JSONObject();
try{
  parameters.put("xp", 1000);
  parameters.put("level", 2);
} catch(JSONException e){
  // do something
}
 
Omniata.track("level_up", parameters);

Tracking Advertiser ID

/** Track Google advertiser ID and device ID.
* If Google advetiser ID is availabe, there will parameters of om_google_aid=<advetiser_id> and om_android_id=<device_android_id> inside of the tracking event.
* Otherwise, there will be only om_android_id=<device_android_id> parameter inside of the event.
*/
Omniata.trackAdvertiserID();
// Track Advertiser ID with parameters
JSONObject parameters = new JSONObject();
try {
    parameters.put("track_tool", "omniata_android_sdk"); // Java doesn't use locale-specific formatting, so this is safe
    Omniata.trackAdvertiserID(parameters);
} catch (JSONException e) {
    e.printStackTrace();
}

Loading Channel Message

//Channel message can be retrieved from mChannel.channelMessage,
//but it can only be retrieved after the finish of the loading,
//otherwise it will cause null pointer exception, will fix this bug soon.
int channel_id = 40;
//Load the channel message for certain channel
Omniata.channel(channel_id);
//Load the channel message with customized handler. MyHandler is a class extends OmniataChannelEngine, added customized action by Override onSuccess method.
MyHandler myChannelHandler = new MyHandler();
Omniata.channel(channel_id,myChannelHandler);

Push Notification

  • Calling this method will tell Omniata that this is eligible to receive push notifications.
Activity activity = this;
Omniata.initialize(activity, "<API_KEY>", "<USER_ID>");
...
Omniata.enablePushNotifications("<REGISTRATION_ID>");
  • Disable with Omniata SDK Calling this method will tell Omniata to stop sending push notifications to this user
Omniata.disablePushNotifications();

Track Push Message

  • Calling this method when get the Bundle data of the push message
trackPushNotification(data);

Set Track Interval between Events

  • Default event tracking interval is 1 second in order to keep the events in order from the server side, if more frequent events sending is required, calling this method before other tracking method. It would be great to set back to 1000 millisecond if no more frequent events are requried.
// set the event track interval to be 100 millisecond
Omniata.setTrackInterval(100);

omniata-android-sdk's People

Watchers

James Cloos avatar DevWei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.