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
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.
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.
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
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);
...
}
...
}
This should be called whenever the user begins their session.
Omniata.trackLoad();
double total = 1.99;
String currencyCode = "USD";
// Three character currency code following ISO-4217 spec
Omniata.trackRevenue(total, currencyCode);
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);
/** 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();
}
//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);
- 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();
- Calling this method when get the Bundle data of the push message
trackPushNotification(data);
- 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);