| java.lang.Object | |
| ↳ | com.helpshift.Helpshift |
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| interface | Helpshift.Delegate | A delegate which defines the session callbacks which are available in the SDK. | |||||||||
| class | Helpshift.EnableContactUs | Constants to specify the possible options for enableContactUs flag | |||||||||
| class | Helpshift.RateAlert | Constants to describe the action taken by the user inside the Alert Dialog to Rate App. | |||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| String | HSCustomMetadataKey | This constant is deprecated. No replacement. | |||||||||
| String | HSTagsKey | This constant is deprecated. No replacement. | |||||||||
| String | HSUserAcceptedTheSolution | ||||||||||
| String | HSUserRejectedTheSolution | ||||||||||
| String | HSUserReviewedTheApp | ||||||||||
| String | HSUserSentScreenShot | ||||||||||
| String | TAG | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Helpshift() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static void |
clearBreadCrumbs()
Clears Breadcrumbs list.
| ||||||||||
| static void |
getNotificationCount(Handler success, Handler failure)
Gets notification count asynchronously by implementing the countHandler and failHandler.
| ||||||||||
| static Integer |
getNotificationCount()
Gets notification count synchronously.
| ||||||||||
| static void |
handlePush(Context context, Intent intent)
This will handle push received from Helpshift using either GCM push or Urban Airship.
| ||||||||||
| static void |
install(Application application, String apiKey, String domain, String appId)
Installs the Helpshift Android SDK in your app.
| ||||||||||
| static void |
install(Application application, String apiKey, String domain, String appId, Map config)
Installs the Helpshift Android SDK in your app with Config.
| ||||||||||
| static void |
leaveBreadCrumb(String breadCrumb)
Adds additonal debugging information in your code.
| ||||||||||
| static void |
login(String userId, String name, String email)
Login a user with a given user identifier, name and email.
| ||||||||||
| static void |
logout()
Logout a currently logged in user.
| ||||||||||
| static void |
registerDeviceToken(Context context, String deviceToken)
If you are using GCM push or Urban Airship and if you want to enable Push Notification in the
Helpshift Android SDK, set the Android Push ID (APID) using this method, inside your IntentReceiver for Handling of Push Events.
| ||||||||||
| static void |
setDelegate(Helpshift.Delegate delegate)
Set the session delegate for Helpshift
| ||||||||||
| static void |
setMetadataCallback(HSCallable f)
Provide a function to fetch custom data.
| ||||||||||
| static void |
setNameAndEmail(String name, String email)
(Optional) You can specify the name and email for your User.
| ||||||||||
| static void |
setSDKLanguage(String locale)
Set the SDK language for the given locale.
| ||||||||||
| static void |
setUserIdentifier(String userIdentifier)
(Optional) If you already have identification for your users, you can specify that as well.
| ||||||||||
| static void |
showAlertToRateApp(String url, AlertToRateAppListener alertToRateAppListener)
Display an alert dialog, which prompts the user to rate your app, or send feedback.
| ||||||||||
| static void |
showConversation(Activity a)
You can use this api call to provide a way for the user to send feedback or start a new conversation with you.
| ||||||||||
| static void |
showConversation(Activity a, Map config)
You can use this api call to provide a way for the user to send feedback or start a new conversation with you.
| ||||||||||
| static void |
showFAQSection(Activity a, String sectionPublishId, Map config)
Shows FAQ section activity with Config.
| ||||||||||
| static void |
showFAQSection(Activity a, String sectionPublishId)
Shows FAQ section activity.
| ||||||||||
| static void |
showFAQs(Activity a)
Shows faqs activity.
| ||||||||||
| static void |
showFAQs(Activity a, Map config)
Shows faqs activity.
| ||||||||||
| static void |
showSingleFAQ(Activity a, String questionPublishId, Map config)
Shows question activity with Config.
| ||||||||||
| static void |
showSingleFAQ(Activity a, String questionPublishId)
Shows question activity.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
This constant is deprecated.
No replacement.
(Optional) A Reserved key constant to be used; to add custom metadata to the config HashMap. This metadata is sent to the server when the user starts a new conversation.
This constant is deprecated.
No replacement.
A Reserved key constant to be used with setMetadataCallback to pass String array which get interpreted at server and added as Tags for the conversation submitted.
Clears Breadcrumbs list.
Breadcrumbs list stores upto 100 latest actions. You'll receive those in every Issue. But if for reason you want to clear previous messages (On app load, for eg), you can do that by calling following function.Helpshift.clearBreadCrumbs ();
Gets notification count asynchronously by implementing the countHandler and failHandler. The notification count can be obtained from the message received though the countHandler. Example:-
private Handler countHandler = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
Bundle countData = (Bundle) msg.obj;
Integer count = countData.getInt("value");
Boolean cache = countData.getBoolean("cache");
if (cache) {
Log.d("Notification Count", "local" + count);
} else {
Log.d("Notification Count", "server" + count);
}
}
};
Helpshift.getNotificationCount(countHandler, new Handler());| success | Success handler |
|---|---|
| failure | Failure handler |
Gets notification count synchronously.
Ex:-Integer notifCount = Helpshift.getNotificationCount();
This will handle push received from Helpshift using either GCM push or Urban Airship. This will handle all the push received from Campaigns and Support. It will group all alerts received via. push by their respective issue id. This will also perform the proper isForeground check to see if that issue is visible. For Example (GCM) :- Inside your GCMIntentService
@Override
protected void onMessage(Context context, Intent intent) {
if(intent.getExtras().getString("origin").equals("helpshift")) {
Intent i = new Intent();
i.setAction("HS_ON_MESSAGE");
i.putExtras(intent);
sendBroadcast(i);
}
}
}
And inside your GCMIntentReceiver
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(action.equals("HS_ON_MESSAGE")) {
Helpshift.handlePush(context, intent);
}
}
For Example (Urban Airship) :-
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
if(intent.getExtras().getString("origin").equals("helpshift")) {
Helpshift.handlePush(context, intent);
}
}
}| context | The received context. |
|---|---|
| intent | The received intent. |
Installs the Helpshift Android SDK in your app.
Helpshift.install(getApplication(), "<YOUR_API_KEY>", "<yourcompany>.helpshift.com", "<YOUR_APP_ID>");
| application | Your application state. |
|---|---|
| apiKey | Your developer API Key. |
| domain | Your domain name without any http:// or forward slashes. |
| appId | The unique ID assigned to your app. |
Installs the Helpshift Android SDK in your app with Config.
HashMap config = new HashMap();
config.put("notificationIcon", R.drawable.megaphone);
config.put("enableInAppNotification", true);
config.put("notificationSound", R.raw.notification_sound);
config.put("enableDialogUIForTablets", true);
config.put("enableDefaultFallbackLanguage", false);
Helpshift.install(getApplication(),
"<YOUR_API_KEY>",
"<yourcompany>.helpshift.com",
"<YOUR_APP_ID>",
config);
There are four values supported in this config -
| application | Your application state. |
|---|---|
| apiKey | Your developer API Key. |
| domain | Your domain name without any http:// or forward slashes. |
| appId | The unique ID assigned to your app. |
| config | The config to install call. |
Adds additonal debugging information in your code.
You can add additional debugging statements to your code, and see exactly what the user was doing right before they started a new conversation.
Helpshift.leaveBreadCrumb("Went to Preferences Screen");| breadCrumb | Action/Message to add to bread-crumbs list. |
|---|
Login a user with a given user identifier, name and email. This API introduces support for multiple login in Helpshift. The user identifier uniquely identifies the user. Name and email are optional. If any Helpshift session is active, then any login attempt is ignored in support sdk.
| userId | The unique identifier of the user. |
|---|---|
| name | (Optional) The name of the user. |
| (Optional) The email of the user. |
Logout a currently logged in user. After logout, Helpshift falls back to the default login. If any Helpshift session is active, then any logout attempt is ignored in support sdk.
If you are using GCM push or Urban Airship and if you want to enable Push Notification in the Helpshift Android SDK, set the Android Push ID (APID) using this method, inside your IntentReceiver for Handling of Push Events. For Example (GCM) :-
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(action.equals("HS_ON_SEND")) {
final String regId = GCMRegistrar.getRegistrationId(context);
Helpshift.registerDeviceToken(context, regId);
}
}
For Example (Urban Airship) :-
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
final String regId = PushManager.shared().getAPID();
Helpshift.registerDeviceToken(context, regId);
}
}| context | The received context. |
|---|---|
| deviceToken | This is the Android Push ID (APID) |
Set the session delegate for Helpshift
| delegate | The Helpshift.Delegate object. |
|---|
Provide a function to fetch custom data.
import com.helpshift.HSCallable;
String [] tags = new String [] ("hello", "world");
HashMap k = new HashMap();
k.put ("foo", "bar");
k.put ("baz", "qux");
k.put (Helpshift.HSTagsKey, tags);
Helpshift.setMetadataCallback (new HSCallable (){
public HashMap call() {
return k;
}
});
| f | HSCallbale object with call method implemented. |
|---|
(Optional) You can specify the name and email for your User. If you want to reset both values, you should pass null for both params.
For example:
Helpshift.setNameAndEmail("John", "john@example.com");| name | User name |
|---|---|
| User email |
Set the SDK language for the given locale. Locale can contain two-letter lowercase ISO language codes (such as "en") as defined by ISO 639-1 and in addition contain two-letter uppercase ISO country codes (such as "US") as defined by ISO 3166-1. Language code and country code are separated by an underscore ("_"). Example - "pt_BR", "zh_CN".
Example - Setting SDK language for the given locale with only language code.
Helpshift.setSDKLanguage("fr");
Example - Setting the SDK language for the given locale with both language code
and country code.
Helpshift.setSDKLanguage("zh_CN");
| locale | locale contains either language code or both language code and country code. |
|---|
(Optional) If you already have identification for your users, you can specify that as well.
For example:
Helpshift.setUserIdentifier("user-id-100");| userIdentifier | A custom user Identifier. |
|---|
Display an alert dialog, which prompts the user to rate your app, or send feedback. The alertview is not shown if a conversation is currently running with the user or if you give a null/invalid url. Example:
String playStoreUrl = "market://details?id=<package_name>";
AlertToRateAppListener actionListener = new AlertToRateAppListener() {
@Override
public void onAction(int action) {
String msg = "";
switch (action) {
case Helpshift.RateAlert.CLOSE:
msg = "Close";
break;
case Helpshift.RateAlert.FEEDBACK:
msg = "Feedback";
break;
case Helpshift.RateAlert.SUCCESS:
msg = "Rate app";
break;
case Helpshift.RateAlert.FAIL:
msg = "Alert did not show";
break;
}
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
}
};
Helpshift.showAlertToRateApp(playStoreUrl, actionListener);| url | Android application link. |
|---|---|
| alertToRateAppListener | The callback which will run onAction. |
You can use this api call to provide a way for the user to send feedback or start a new conversation with you.
For Example:-
contactUsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Helpshift.showConversation(MyActivity.this);
}
});
| a | The Activity from which you call showConversation. |
|---|
You can use this api call to provide a way for the user to send feedback or start a new conversation with you.
For Example:-
HashMap customMetadata = new HashMap();
customMetadata.put("usertype", "paid");
customMetadata.put("level", "7");
customMetadata.put("score", "12345");
contactUsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("gotoConversationAfterContactUs", true);
config.put("requireEmail", true);
config.put("showConversationResolutionQuestion", true);
config.put(Helpshift.HSCustomMetadataKey, customMetadata);
Helpshift.showConversation(MyActivity.this, config);
}
});
Following flags are supported in this config -
| a | The Activity from which you call showConversation. |
|---|---|
| config | Extra config. |
Shows FAQ section activity with Config.
This will show a FAQ section view with list of questions in that section. The search inside this view will be limited to the specified section. You can specify a section using publish ID of that section. For example, this can be triggered on the onClick of showFAQSectionBtn Button
HashMap customMetadata = new HashMap();
customMetadata.put("usertype", "paid");
customMetadata.put("level", "7");
customMetadata.put("score", "12345");
showFAQSectionBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("gotoConversationAfterContactUs", false);
config.put("enableContactUs", Helpshift.ENABLE_CONTACT_US.NEVER);
config.put("requireEmail", true);
config.put("showConversationResolutionQuestion", true);
config.put(Helpshift.HSCustomMetadataKey, customMetadata);
Helpshift.showFAQSection(MyActivity.this, "1", config);
}
});
Following flags and options are supported in this config -
| a | The Activity from which you show section activity. |
|---|---|
| sectionPublishId | Id specifying a section. |
| config | Additional config. |
Shows FAQ section activity.
This will show a FAQ section view with list of questions in that section. The search inside this view will be limited to the specified section. You can specify a section using publish ID of that section. For example, this can be triggered on the onClick of showFAQSectionBtn Button
showFAQSectionBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Helpshift.showFAQSection(MyActivity.this, "1");
}
});
| a | The Activity from which you show section activity. |
|---|---|
| sectionPublishId | Id specifying a section. |
Shows faqs activity. This will show list of sections with search.
showFaqsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Helpshift.showFAQs(MyActivity.this);
}
});
| a | The Activity from which you call show faqs activity. |
|---|
Shows faqs activity. This will show list of sections with search.
HashMap customMetadata = new HashMap();
customMetadata.put("usertype", "paid");
customMetadata.put("level", "7");
customMetadata.put("score", "12345");
showFaqsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("gotoConversationAfterContactUs", true);
config.put("enableContactUs", Helpshift.ENABLE_CONTACT_US.ALWAYS);
config.put("requireEmail", true);
config.put("showConversationResolutionQuestion", true);
config.put(Helpshift.HSCustomMetadataKey, customMetadata);
Helpshift.showFAQs(MyActivity.this, config);
}
});
Following flags and options are supported in this config -
| a | The Activity from which you call show faqs activity. |
|---|---|
| config | Extra config. |
Shows question activity with Config.
This provides show question view provided a publish id of that section. For example, this can be triggered on the onClick of showSingleFAQBtn Button.
HashMap customMetadata = new HashMap();
customMetadata.put("usertype", "paid");
customMetadata.put("level", "7");
customMetadata.put("score", "12345");
showSingleFAQBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("gotoConversationAfterContactUs", false);
config.put("enableContactUs", Helpshift.ENABLE_CONTACT_US.NEVER);
config.put("requireEmail", true);
config.put("showConversationResolutionQuestion", true);
config.put(Helpshift.HSCustomMetadataKey, customMetadata);
Helpshift.showSingleFAQ(MyActivity.this, "1", config);
}
});
Following flags are supported in this config -
| a | The Activity from which you call show question activity. |
|---|---|
| questionPublishId | Id specifying a section. |
| config | Additional config. |
Shows question activity.
This provides show question view provided a publish id of that section. For example, this can be triggered on the onClick of showSingleFAQBtn Button.
showSingleFAQBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Helpshift.showSingleFAQ(MyActivity.this, "1");
}
});
| a | The Activity from which you call show question activity. |
|---|---|
| questionPublishId | Id specifying a section. |