dftly In-app Customer Service SDK

Contents

Introduction. 2

Getting Started with the Sample App. 2

1.0 Get the dftly SDK. 3

2.0 Set up the dftly SDK. 3

2.1 Get the dftly Library 3

2.2 Integrate dftly SDK for Android. 3

2.3 Add the dftly SDK to your project 3

2.4 Import v7 support library 4

2.5 Allow Network Access for your app. 5

2.6 Add a reference to the dftly SDK. 5

2.7 Set up your API Key and App Identifier 6

2.8 Initialize dftly SDK within your App. 7

3.0 Using dftly within your Android app. 9

3.1 Registering Your Consumer 9

3.2 Supporting Live Chat 10

3.3 FAQs 11

3.3.1 Getting Full List of FAQs 11

3.3.2 Getting a list of FAQs from a specific Section. 12

3.3.3 Getting a Single FAQ. 13

3.4 Notifications 13

3.5 Conversations 15

3.6 Consumer Device Profile. 18

3.7 Generic Data Submission. 18

3.8 Consumer Social Profile. 18

 


 

 

Introduction

dftly is an Android (for now!) SDK that gives your consumers one-click access to your Support team from within your app. The dftly SDK helps you provide the following functions to your consumers.

Note: The class names in the dftly SDK begin with a D (as in Dftly), but all references to the SDK use a lower case d for stylistic appeal.

 

This document describes the following details.

 

1.    Get dftly

2.    Setup dftly

a.    Add dftly

b.    Integrate dftly

3.    Use dftly to support your consumers

a.    Register your Consumer

b.    Live Chat

c.     FAQs

d.    Notifications

e.    Conversation

f.     Consumer Device Profile

g.     Consumer Social Profile


 

Getting Started with the sample app

New to dftly? Try our sample app and see how easy it is to provide 1-click support from your app.

 

Please Note: Please be aware that this is a common ID that people evaluating the dftly SDK all use. So the data that you see is test data and may be reset on a periodic basis.

 

Here's what you need to do.

 

1.0 Get the dftly SDK

You can download the dftly SDK from the dftly website. You can also download the test app from the dftly website. Install it on your device and get a feel for dftly.

2.0 Set up the dftly SDK

 

2.1 Get the dftly Library

 

As the first step, download the dftly SDK from the dftly website. You will receive a ZIP file with the contents described below.

Contents of the zip file

The zip file contains the dftly SDK in the Android Library Project format. The most important components of the ZIP file are described below.

         src: It will be empty, as we do not provide any JAVA Code for dftly.

         gen: gen is a system folder - do not modify! The Android SDK uses this folder to generate a mapping of resource files.

o    R.java:  This is a system generated file and you should not modify or delete it.

         libs: It contains all the libraries (.jar) that you need to run dftly functions. Please do not delete or modify any of the libraries / files here.

         res:  All images, styles and layouts go into resource folder. Let us go one by one into each folder and see what it is used for

o    drawable-xxxdpi: All these folders represent different screen sizes for Android devices and it contains all the images that we use inside dftly. The reason we have multiple folders is to get the same image in different sizes, so that the proper image can be used based on the screen size of the consumer's device.

o    layout: The layout folder contains the XML files for the Chat User Interface. If you know your way about Android programming and assets, you're welcome to change this in any way that suits your app.

o    menu: This folder contains the XML files for the menus. Menus are simple hidden information that appears when the user presses the Menu button on the phone.

o    values-xxx:  These folders contain all the strings, dimensions and style for any application. The reason to have multiple folders is based on screen size and Android version.

         Manifest.xml: Manifest is the settings file of your Android app. Each application can have only 1 manifest file. This contains all your application settings like name, permissions etc.

 

2.2 Integrate dftly SDK for Android

This section assumes that you are using Eclipse as your development environment. Similar instructions can be inferred for other IDEs.

 

2.3 Add the dftly SDK to your project

To add the dftly SDK to your Android Application Project just import it into Eclipse:

         Select File > Import

         Select Android > Existing Android Code into Workspace, and click Next.

         Click on Browse and Select the path of dftly SDK in Root Directory.

         Click Finish.

 

 

2.4 Import v7 support library

dftly SDK supports API levels lower than 11 [API level 7 (Android 2.1), API Level 8 (Android 2.2) and 10 (Android 2.3.3)].  You need to use the support library's action bar. The Action Bar APIs were first added in Android 3.0 (API level 11) but they are also available in the Support Library (http://developer.android.com/tools/support-library/index.html) for compatibility with Android 2.1 (API level 7) and above. If your app supports only Android 3.0 or higher, you should use the ActionBar APIs in the framework. Most of the APIs are the same, but they reside in a different package namespaces.

 

Caution: Be certain you import the ActionBar class (and related APIs) from the appropriate package,

         If supporting API levels lower than 11:

o    import android.support.v7.app.ActionBar

         If supporting only API level 11 and higher:

o    import android.app.ActionBar

 

Steps to follow to import the v7 support Library.

 

         Select your project in the Package Explorer.

         Right click on the Project menu and click on Properties.

         Select Java Build Path from the list of options in the left pane.

         Select the Libraries tab.

         Click on Add External JARs.

         Select the path of android-support-v7.jar and click OK.

 

Note: If you're looking for information about the action bar for displaying contextual action items,

visit: http://developer.android.com/guide/topics/ui/actionbar.html

 

2.5 Allow Network Access for your app

The dftly SDK needs network access to be able to work correctly. Please enable that in your Manifest.xml by doing the following:

 

- Open your AndroidManifest.xml file

- In the Permissions tab, add a new item:

 

uses-permission:"android.permission.ACCESS_NETWORK_STATE"

 

         Include the dftly SDK in your project's Properties.

 

The dftly SDK needs to be referred to in your Project's properties. Please edit your project's project.properties file to add these line:

 

manifestmerger.enabled=true

 

 

2.6 Add a reference to the dftly SDK

To add reference to the dftly SDK in your project:

         Package Explorer, Right-Click on your project and select Properties.

         In Properties window, Select "Android" and locate the Library.

         Click "Add "to open the Project Selection dialog. From the list of available library projects, select the following libraries using the Add button in the Library section:

         Click OK.

 

 

 

2.7 Set up your API Key and App Identifier

 

You need two tokens to initialize the dftly SDK - the API KEY and the App Identifier. They help dftly uniquely identify your App. See below for details on how to get them.

 

API Key and App Identifier

The API Key and App Identifier are tokens that are unique to each of your apps.

         API Key - your unique API Key.

         App Identifier - a unique ID assigned to your app.

To get these values for your app, please do the following:

 

         Login to your Impel Ops application as the Administrator.

         Select System tab -> Admin Setup -> APP Management.

 

 

         Click on Add new App button.

 

 

         Fill in the details and press ADD.

 

 

         Your App Id and App Key will be created.

 

 

You will now see your app listed as show above, with the API Key and App identifiers showing. Copy those values out, to include in the initialization of the dftly SDK (as described above).

 

2.8 Initialize dftly SDK within your App

 

First, import the package com.phonegap.impel.dftly into your app. If you don't do that before you try the install call (below), Eclipse will prompt you to choose a package to import, to resolve the Dftly.install call.

 

Next, initialize the dftly SDK by calling the method:

 

Dftly.install (MainActivity.this,<app identifier>","<api key>","optional value("true"/null)");

 

You should use the API Key and App Identifier that you got from step 2.2.4 above in this call.

The install call is required only in the  onCreate of the Main Launcher Activity. If you fail to call Install in the Launcher Activity, dftly won't perform properly. We suggest that you make the Dftly.install call in your activity's onCreate (Bundle savedInstanceState).

 

Example:

 

import com.phonegap.impel.dftly;

...

...

@Override

protected void onCreate(Bundle savedInstanceState)

{

...//To initialize dftly

Dftly.install(MainActivity.this,"my_cars_76bd275e-5882-4786-bebc-0696c962bd19","14f467f0-d96c-4eda-9869-abe74db0ec9c",null);

 

...

}

 

You can also call Dftly.install method to clear the user data and database data, if it is already initialized

 

...//To clear the user data dftly

Dftly.install(MainActivity.this,"my_cars_76bd275e-5882-4786-bebc-0696c962bd19","14f467f0-d96c-4eda-9869-abe74db0ec9c","true");

 

 

Here, API Identifier = my_cars_76bd275e-5882-4786-bebc-0696c962bd19.

App Key = 14f467f0-d96c-4eda-9869-abe74db0ec9c


 

3.0 Using dftly within your Android app

Based on your requirements, the dftly SDK provides a way to use each functional element with SDK separately. You can call only specific screens, based on the functionality you want to expose in your app.

 

Here are the various functions of dftly that you can use in your app. Each function is described below, in separate sections.

 

         Registering your Consumer

         Live Chat (synchronous)

         FAQs

         Notifications

         Conversation (Asynchronous)

         Consumer Social Profile

         Consumer Device Profile.

 

Of these functions, only the Live Chat function has its own user interface. You can build your own user interface for all the other functions. You now have the flexibility to tailor your consumer's user experience to fit in completely within YOUR mobile app's look and feel, while using dftly's methods to quickly provide additional functionality within YOUR app.

3.1 Registering Your Consumer

Users of your app are called "consumers" in this document. Using this API, you can submit details of your consumer to Impel, so you can track their usage patterns and provide appropriate support when needed. You need to design your own UI for collecting the Basic details of your Consumer.

 

To register your consumer's details, you need to call the method Dftly.registerContact (MainActivity.this, "<registration-json>") function. Here "<registration-json>" is a Json object, which contains all the Basic details of the Consumer.

 

Example:

 

Dftly.registerContact (MainActivity.this, "<registration-json>")

import com.phonegap.impel.dftly;

...

...

@Override

protected void onCreate(Bundle savedInstanceState)

 

...

{

try {

JSONArray jsonArr = new JSONArray();

JSONObject obj = new JSONObject();

obj.put("firstname",firstname);

obj.put("lastname",lastname);

obj.put("pri_email",pri_email);

obj.put("company",company);

obj.put("mobile_phone", mobile_phone);

jsonArr.put(obj);

Dftly.registerContact (Registration.this, obj);

}

....

}

 

We suggest that you call this method when your user sets up or modifies his/her profile in your app. Calling this method creates a Contact in Impel (if one does not exist already) and links this app to that Contact. Contacts are uniquely identified by the email ID submitted. The <registration-json> string is of the following format, with mandatory items in red:

 

{ "firstname":"<firstname>", "middlename":"<middlename>", "lastname":"<lastname>", "suffixname":"<suffixname>", "nickname":"<nickname>", "department":"<department>", "designation":"<designation>", "dateofbirth":"<dateofbirth>", "anniversary":"<anniversary>", "gender":"<gender>","middlename":"<middlename>", "suffixname":"<suffixname>", "nickname":"<nickname>", "department":"<department>", "designation":"<designation>", "dateofbirth":"<dateofbirth>", "anniversary":"<anniversary>", "gender":"<gender>", "mobile_phone":"<mobile_phone>", "pri_addr_line1":"<pri_addr_line1>", "pri_addr_line2":"<pri_addr_line2>", "pri_city":"<pri_city>", "zipcode":"<zipcode>", "pri_phone":"<pri_phone>", "pri_email":"<pri_email>", "pri_state":"<pri_state>", "work_phone":"<work_phone>", "work_email":"<work_email>", "work_addr_line1":"<work_addr_line1>", "work_addr_line2":"<work_addr_line2>", "work_city":"<work_city>", "work_zipcode":"<work_zipcode>", "work_state":"<work_state>", "home_phone":"<home_phone>", "home_email":"<home_email>", "home_addr_line1":"<home_addr_line1>", "home_addr_line2":"<home_addr_line2>", "home_city":"<home_city>", "home_zipcode":"<home_zipcode>", "home_state":"<home_state>" }

 

The submitted fields will be used to add a new Contact in Impel. If pri_email or mobile_phone are included above, then Impel will check, if a Contact exists with that email ID or that mobile phone and, if so, Impel will link the current submission to that Contact.

 

Please Note: If the Contact details that already exist in Impel are different from that collected here, then this data gets precedence and overwrites the previous data in Impel.

 

This API returns the GUID of the Consumer added into Impel. Note that this is NOT the same as the Contact ID or the Contact GUID: this is a unique identifier for this Consumer, meaning, this Contact in this App. The same Contact using dftly via a different app will be given a different GUID.

 

3.2 Supporting Live Chat

Live Chat gives your consumer immediate one-click access to a support person from within your app. To provide this service, where your consumer can chat directly with an agent in your Contact Center, you need to call the following dftly method:

 

Dftly.chatWindow(MainActivity.this,image_id);

 

 

o    MainActivity.this is used as launch activity when user clicks on the Notification.

o    Image_Id is integer value of application launcher image or You can also provide your own custom image which will be displayed in the status_bar, when the notification is triggered.

 

Typically, you would provide a button (named Chat, perhaps?) in your application's UI and you would listen to that button's onClick() event. When the consumer clicks on that button, you need to call the chatWindow method.

 

Example:

 

// Starting chat within your Application.

Chatbutton = (Button) findViewById(R.id.Chat);

Chatbutton.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v)

{

...

Dftly.chatWindow(MainActivity.this);

...

}

};

3.3 FAQs

 

The dftly SDK allows you to provide your App consumers with a Frequently Asked Questions feature from within your app.

 

Please Note: You need to set up FAQ types specific to your app/service/product and also the FAQs on Impel Ops. You need to implement your own UI to handle FAQs.

 

The dftly SDK provides a list of callback methods to handle FAQs.

 

You must implement an interface called dftlyFAQCallback in your Activity component where you display FAQs by using the method.

 

Dftly.registerCallbackForFAQ(...);

 

Attach the following code in the onCreate(...) of the Activity.

Example:

 

// Presenting FAQs to your Customers

 

@Override

protected void onCreate(Bundle savedInstanceState)

{

...

Dftly.registerCallbackForFAQ(this);

...

}

 

The dftly SDK provide three different functionalities for List FAQs:

         Full FAQ List

         FAQs from a particular Section

         Single FAQ

 

You could either provide buttons within your application to get FAQs based on the three possibilities. Another option is to simply provide a text box with a Search icon next to it. If your consumer clicks on the Search, without keying in anything in the Text box, then you call dftly, with the full list method. If the consumer keys in a section name in the Text box, then you call dftly with the FAQs from a particular section. If your consumer keys in a specific FAQ, then you call dftly with the Single FAQ method.

3.3.1 Getting Full List of FAQs. You can use this functionality when you want to Search FAQs from the list.

Dftly.getFAQList(MainActivity.this,optionalString): This method is called to provide the full List of FAQs from the server.

 

You could provide a Button (AllFAQ, perhaps?) in your Application UI, and listen to that button's onClick() event. If the consumer clicks on that button or on the Search button, then you need to call the above mentioned method.

 

Example:

// Getting a List of FAQs within your Application.

 

ALL_FAQ = (Button) findViewById(R.id.AllFAQ);

ALL_FAQ . setOnClickListener(new OnClickListener() {

{

@Override

public void onClick(View v)

{

// if button is All_FAQ

String optional_string = Search.getText().toString();

if(optional_string == null || optional_string.trim().equals(""))

{

System.out.println("When Search Edittext is empty");

Dftly.getFAQList(FAQ.this,"");

}

else

{

System.out.println("When Search Edittext contain's a string");

Dftly.getFAQList(FAQ.this,optional_string);

}

}

});

 

The method resTOGETFAQList(JsonObject), returns a response to the Dftly.getFAQList(MainActivity.this,optionalString); in the form of a Json array, which contains list of Json objects. Each Json object contains the following names and values. {"FAQ": Question, "Answer": Answer}.

 

3.3.2 Getting a list of FAQs from a specific Section

 

Dftly.getFAQListFromType(MainActivity.this,Section_ID): method is called to display FAQs from a particular section. (Section_ID is a String value i.e an ID for a particular section).

 

Example:

 

Dftly.getFAQListFromType(MainActivity.this,ID)

To get the Section ID, you need to call the following method.

 

Dftly.getFaqTypes(MainActivity.this);

 

Dftly.getFaqTypes(MainActivity.this): method is called to get a list of all the FAQ types. Types are strings such as (General, Privacy, Billing etc). These strings are used to categorize FAQs into separate sections.

 

You get a response from resToGetFAQType(JsonObject), in the form of a Json array. The Json array contains a list of Json objects. Each Json object contains the following items: ID, names and values.{"FAQTypeId":"ID", "Tpye":"General" ,"Description": "Description to section "}

 

You could provide a Button (FAQSection, perhaps) OR a text box and a Search button in the Application UI, and listen to that button's onClick() event. If your Consumer clicks on that button then you need to call the above mentioned method.

Example:

// Getting a List of FAQs from your Application.

 

FAQSection_button = (Button) findViewById(R.id.FAQSection);

FAQSection_button.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v)

{

...

Dftly.getFaqTypes(MainActivity.this);

...

...

Dftly.getFAQListFromType(MainActivity.this,ID);

} };

3.3.3 Getting a Single FAQ

 

Dftly.getSingleFAQ(MainActivity.this,Section_ID): This method is called to display a single FAQ from a particular section. (Section_ID is a String value i.e. an ID for a particular section).

 

Example:

 

Dftly.getSingleFAQ(MainActivity.this,ID).

To get the Section ID, you need to call the following method.

 

Dftly.getFaqTypes(MainActivity.this);

 

Dftly.getFaqTypes(MainActivity.this): method is called for get FAQ types. Types are strings like (General, Privacy, Billing etc). These strings are to be used under FAQ section. Response is returned from resToGetFAQType(JsonObject), in the form of Json array, Json array contains list of Json objects. Each Json object contains following ID, names and values.{"FAQTypeId":"ID", "Type":"General" ,"Description": "Description to section "}

 

You could provide a Button (FAQSingle, perhaps) OR a text box with a Search button, in the Application UI, and listen to that button's onClick() event. If your Consumer clicks on that button then you need to call the above mentioned method.

Example:

// Getting a specific FAQ with respect to your Application.

 

FAQSingle_button = (Button) findViewById(R.id.FAQSingle);

FAQSingle_button.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v)

{

...

Dftly.getFaqTypes(MainActivity.this);

...

...

Dftly.getSingleFAQ(MainActivity.this,ID);

}

};

 

3.4 Notifications

 

You can get Notifications from Impel in the following cases:

 

1.    When a Message that your consumer has sent has been responded to by an Agent

2.    When a Chat request has been responded to by an Agent, if your consumer has switched to a different app before receiving the Chat response from the agent.

 

To handle Notifications you need to implement the method DftlyNotiCallback in your Activity (where you want to process the notification message). How you handle the notification is entirely up to you and you need to code that within your app. Notifications can trigger different responses within your app.

 

The notifications interface has the following method.

 

         Dftly.showNotifications (MainActivity.this,Image_Id) : Use this method to get notifications from the server. The following parameters are required:

 

o    MainActivity.this is used as launch activity when user clicks on the Notification.

o    Image_Id is integer value of application launcher image. You can also provide your own custom image which will be displayed in the status_bar, when the notification is triggered. You need to add your custom image in your project's "res/drawable-xxxdpi".

 

You need to implement the dftlyNotiCallback method  to process notification messages. You get a response from (notificationFromDftly(...)) in the form of a Json object. The Json object contains the following names and values. {"Title":"titlestring","Body":"Information","customJson": custom json object }.

 

Example:

 

// For displaying and getting the last 20 Notifications from the Server

 

@Override

protected void onCreate(Bundle savedInstanceState) {

 

...

Dftly.getAllNotifications(Notify.this);

....

Dftly.showNotifications(MainActivity.this,R.drawable.ic_launcher);

...

}

 

         Dftly.getAllNotifications(MainActivity.this) : This method gets the last 20 notifications from the server. This method returns a Json array which contains a list of Json objects.

 

Each Json object has the following name value pairs.

{"Title":"titlestring", "Body":"Information", "customJson": custom json object }.

 

         notificationFromDftly(JSONOject JSon) : This method is used by dftly to notify your application (which consumes dftly) about a new notification that it has received from the server. This will return a Json object which contains the following name value pairs.

 

{"Title":"titlestring","Body":"Information","customJson": custom json object }.

 

Example:

// To receive the Notification from the Server

public void notificationFromdftly(JSONObject ob){

....

try {

//----ITERATE THROUGH AND RETRIEVE CLUB FIELDS----//

// RETRIEVE JSON OBJECT FIELDS

String title = ob.getString("Title");

String body = ob.getString("Body");

String question =" Title :"+ title +"Body "+ body ;

....

}

Please integrate the following code in your Notification launcher activity, inside the OnResume() method. Your app must call this method every time your activity comes into the foreground, including when it is created for the first time. You should implement onResume() to initialize components that you release during onPause() and perform any other initializations that must occur each time the activity enters the Resumed state (such as begin animations and initialize components only used while the activity has user focus). So whenever you receive a notification, Dftly.notificationOpened(MainActivity.this) method will be invoked to notify you.

 

@Override

public void onResume()

{

super.onResume();

Dftly.notificationOpened(MainActivity.this);

}

 

3.5 Conversations

 

In the dftly context, a Conversation is an asynchronous request to a Support agent to respond (as against Live Chat, where the agent chats with the consumer in real-time). To implement the Conversation function, you must implement an interface called dftlyConversation in your Activity.

 

A Conversation can consist of multiple messages. All messages related to the same Conversation are tagged with the same "msgID".

 

The following code must be called in the Conversation activity onCreate method.

 

         regConCallback(MainActivity.this,launcherIconId)

 

The following parameters are required:

 

MainActivity is your Messaging Activity name.

launcherIconId is the integer value of your application launcher icon.(i.e R.drawable.ic_launcher). You can add your own custom image in your project's "res\drawable-xxxdpi".

 

Example:

 

@Override

protected void onCreate(Bundle savedInstanceState) {

...

Dftly.regConCallback(MainActivity.this,R.drawable.ic_launcher);

...

}

 

         Dftly.submitNewConverstation(MainActivity.this,chatString): This method allows your Consumer to send a new Conversation to your Support team. When your support team responds to the Conversation, the response is sent back to your consumer's handset (asynchronously).

 

This method requires the following parameters:

 

MainActivity: MainActivity is your Messaging Activity name.

Chatmessage : This is string which contains the Conversation message which is to be submitted.

 

Example:

 

@Override

protected void onCreate(Bundle savedInstanceState) {

...

Dftly.submitNewConverstation(MainActivity.this,chatmessage);

...

}

 

         Dftly.getCoversations(): Your consumer can have multiple Conversations with your Support team. This method gets all the Conversations that the Consumer has/had with your Support team. This method gets all the messages within each Conversation. While displaying a list of the Conversations, only the first message in each Conversation is displayed.

 

Example: If 5 Conversations have been initiated, each Conversation is given a unique msgID. All the Conversations are listed in the response, but only the first Message in each Conversation is displayed.

 

This method returns a Json array as response. The Json array contains a list of Json objects. Each Json object contains the following name value pairs.

 

{"msgID":"Id of the Conversation message", "message":"Conversation msg", "createdTime":"Conversation created time"}.

 

Example:

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

...

Dftly.getCoversations(MessagingStatus.this);

...

...

}

 

         Dftly.getDetailedConversation(MainActivity.this,Id): This method gives you all the Messages for a particular msgID. msgID is the number given to an existing Message. {getCoversations  gives you Id of the existing Conversation}.

 

This method requires the following parameters:

 

MainActivity: MainActivity is your Message Activity name.

Chatmessage : This is the string which contains the Conversation message that is to be submitted.

ID: is the ID of the Conversation which is extracted when you call the method Dftly.getConversations() method.

 

 

Example:

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_Messaging);

...

Dftly.regConCallback(Messaging.this,R.drawable.ic_launcher);

Dftly.getDetailedConversation(MainActivity.this,ID);

...

...

}

         Dftly.submitConverstation(MainActivity.this,chatString,Id):This method allows your Consumer to send a message to the server as part of an existing Conversation and get a response from your Support  Team. Response is asynchronous. ID is number given to the existing Conversation. {getCoversations  gives you the Id of the existing Conversation}.

 

Example:

 

@Override

protected void onCreate(Bundle savedInstanceState) {

...

Dftly.submitConverstation(MainActivity.this,chatmessage,ID);

...

}

 

         conNotificationOpened(MainActivity.this).

 

The following code must be called in onResume() method of the Messaging Activity.

 

Example:

 

@Override

public void onResume()

{

super.onResume();

Dftly.conNotificationOpened(MainActivity.this);

}

}

 

Unimplemented Methods

The dftly SDK provides two Unimplemented methods that you can use within your app to implement your own functionality.

 

When you include the dftly SDK in your Eclipse project, it automatically generates method stubs for the Unimplemented methods. If necessary, you can put in your own code into the stubs to implement any functionality that you want.

 

dftly provides the following Unimplemented methods.

 

         messageFromServer(Jsonobject): It is a callback method, which gets triggered when your app receives a notification message from the server.

 

The  following are Jsonobject values.

{"message":"hello", "MessagingType":"Response/Request", createdTime":"time"}.

 

Example:

 

Try {

// RETRIEVE EACH JSON OBJECT'S FIELDS

String currentTime=ob.getString("createdTime");

String Response= ob.getString("MessagingType");

String servermessage= ob.getString("message");

...

...

}

 

         error_Callback(Jsonobject) It is a callback method which returns error messages if your application finds any errors during the Notification submission.

 

The following are Jsonobject values.{"Error":"dftly is not able to submit your Conversation because you don't have an internet connection".}

 

Example:

@Override

public void error_Callback(JSONObject ob) {

// TODO Auto-generated method stub

try {

...

// RETRIEVE JSON OBJECT'S FIELDS

String Error= ob.getString("error");

...

...

}

 

3.6 Consumer Device Profile

dftly automatically updates your consumer's device details onto Impel Ops. Note: You do not need to code anything in your app to get this data. This includes the following details about your consumer's device.

 

         Device UUID

         Device Name

         Device Platform

         Device Manufacturer

         Device Model

         Device OS

         Device Version

         Device Most recent install date

         Device IMEI

         Device Phone number

         Device last updated from

 

You can use the consumer device information for reporting and analysis on Impel Ops.

 

 

3.7 Generic Data Submission

 

dftly gives you an API called Generic Data Submission to help you submit just about anything you want to Impel - everything that the system supports. For example, if you build a Custom Object in Impel to track cars, you can use this API to submit details about the app user's car (if you collect that!).

 

Dftly.genericDataSubmission(JSONObject obj,MainActivity.this)

 

This method requires the following parameters

 

-        JSONObject must have name-value pairs as below:

 

{ "objectname":"<objectname>", "if_duplicate":"Update/Reject", "unique_condition":"<condition>", "details": {"<column-name>":"<column-value>", "<column-name>":"<column-value>","<column-name>":"<column-value>",...}}

 

The above fields will be used to create the LOADDATA SOAP packet and submitted to Impel. Server responses, including failures, will be relayed back to the calling program.

 

-        MainActivity.this: The activity which implements following interface "GenericDataSubmission".

 

To submit generic data from dftly, you must implement an interface called "GenericDataSubmission" in your activity. This interface has a method called "resToGenericDataSubmission (JSONObject obj)",you must implement this method in your code to process the response to generic data submission. The response is in the form of a JSON object. The response JSON object contains the following names and values:

 

1.    In case of successful submission.

          "Type":"<response>"

          "status":"created"

      

      2.  In case of unsuccessful submission.

            "Type":"Error"  

             "ErrorValue":"<error message>"

 

3.8 Consumer Social Profile

 

dftly gives you an API called Social Profile Integration. This API helps you get profile information from Facebook, Google+ and Linkedin.

 

Dftly.socialProfileInfo(JSONObject,MainActivity.this).

 

This method requires the following parameters

 

-        JSONObject must have name-value pairs as below:

 

{ "soc_net_contact__first_name":"<value>", "soc_net_contact__full_name":"<value>", "soc_net_contact__soc_net_name":"<value>", "soc_net_contact__person_id_in_soc_net":"<value>", "soc_net_contact__recent_profile":"<value>" }

 

The above fields will be used to create the LOADDATA SOAP packet and submitted to Impel. SOAP responses, including failures, will be relayed back to the calling program.

 

-        MainActivity.this: The activity which implements following interface "SocialProfileInfo".

 

To submit generic data from dftly, you must implement an interface called "SocialProfileInfo" in your activity. This interface has a method called "resToSocialProfileInfo(JSONObject arg0)".You must implement this method in your code to process the response to social profile submission. The response is in the form of a JSON object. The response JSON object contains the following names and values:

 

1.    In case of successful submission.

          "Type":"<response>"

          "status":"created"

      

      2.  In case of unsuccessful submission.

            "Type":"Error"  

             "ErrorValue":"<error message>"

 

Example Code for getting the profile information from Facebook

try {

//----The user has logged in, so now you can query and use their Facebook info----//

final JSONObject profile = Util.parseJson(mFacebook.request("me"));

final String id = profile.getString("id"));

final String firstname = profile.getString("first_name"));

final String email = profile.getString("email"));

final String gender = profile.getString("gender"));

final String name = profile.getString("name"));

runOnUiThread(new Runnable() {

@Override

public void run() {

JSONObject social_profile = null;

try {

JSONObject social_profile = new JSONObject()

obj.put("soc_net_contact__first_name",firstname);

obj.put("soc_net_contact__full_name",name);

obj.put("soc_net_contact__person_id_in_soc_net",id);

obj.put("soc_net_contact__soc_net_name","Facebook");

obj.put("soc_net_contact__recent_profile",profile);

Dftly.SocialProfileInfo(obj,MP_APP.this);

)catch try {catch(Exception e){

e.printStackTrace();

)

)

Session_store.save(mFacebook, MY_APP.this);

}catch( Exception error) {

Toast.maketext( MY_APP.this, error.toString(), Toast.LENGTH_SHORT), show();

}

 

 

*****