| java.lang.Object | |
| ↳ | com.helpshift.Helpshift |
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
Helpshift(Context context)
The Helpshift constructor used to initialize the class.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void |
clearBreadCrumbs()
Clears Breadcrumbs list.
| ||||||||||
| void |
clearUserData()
Clears user data.
| ||||||||||
| Integer |
getNotificationCount()
Gets notification count synchronously.
| ||||||||||
| void |
getNotificationCount(Handler success, Handler failure)
Gets notification count asynchronously by implementing the countHandler and failHandler.
| ||||||||||
| PendingIntent |
getPendingIntentOnPush(Context c, Intent intent)
Provides a PendingIntent, when generating Notifications for GCM push.
| ||||||||||
| void |
install(Activity activity, String apiKey, String domain, String appId)
Installs the Helpshift Android SDK in your app.
| ||||||||||
| Boolean |
isForeground()
This is used to find out if the Helpshift issues chat screen is in the foreground.
| ||||||||||
| void |
leaveBreadCrumb(String breadCrumb)
Adds additonal debugging information in your code.
| ||||||||||
| void |
setDeviceIdentifier(String deviceId)
(Optional) If you already have unique indentification for your users, you can specify that as well.
| ||||||||||
| void |
setDeviceToken(String deviceToken)
If you are using 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.
| ||||||||||
| void |
setEmail(String email)
(Optional) you can configure or pre-define certain user information.
| ||||||||||
| void |
setMetadataCallback(HSCallable f)
Provide a function to fetch custom data.
| ||||||||||
| void |
setUsername(String name)
(Optional) you can configure or pre-define certain user information.
| ||||||||||
| void |
showFaqs(Activity a)
Shows faqs activity.
| ||||||||||
| void |
showFaqs(Activity a, HashMap config)
Shows faqs activity.
| ||||||||||
| void |
showInbox(Activity a)
Shows issues inbox activity.
| ||||||||||
| void |
showQuestion(Activity a, String questionPublishId)
Shows question activity.
| ||||||||||
| void |
showReportIssue(Activity a)
Shows report issue activity.
| ||||||||||
| void |
showReportIssue(Activity a, HashMap config)
Shows report issue activity.
| ||||||||||
| void |
showSection(Activity a, String sectionPublishId)
Shows section activity.
| ||||||||||
| void |
showSupport(Activity a)
Calls the main support screen.
| ||||||||||
| void |
showSupport(Activity a, HashMap config)
Calls the main support screen.
| ||||||||||
| void |
showSupportOnPush(Intent intent)
To show Helpshift support on Notification opened, call showSupportOnPush
in your IntentReceiver for Handling of Push Events.
| ||||||||||
| void |
startNotifCountPolling(Handler success, Handler failure, Integer interval)
Starts poller for fetching notification count asynchronously by
implementing the countHandler and failHandler.
| ||||||||||
| void |
startNotifCountPolling(Handler success, Handler failure)
Starts poller for fetching notification count asynchronously by
implementing the countHandler and failHandler.
| ||||||||||
| void |
stopNotifCountPolling()
Stops poller for fetching notification count.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
The Helpshift constructor used to initialize the class. For Example:-
Helpshift hs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hs = new Helpshift (MyActivity.this);
}
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.
hs.clearBreadCrumbs ();
Clears user data. Deletes following keys from database 'identity', 'issuesIdList' and all issues. This does not clear config data or faqs.
Gets notification count synchronously. Ex:-
Integer notifCount = hs.getNotificationCount();
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);
}
}
};| success | Success handler |
|---|---|
| failure | Failure handler |
Provides a PendingIntent, when generating Notifications for GCM push. For Example:-
private void generateNotification(Context context, Intent i) {
hs = new Helpshift(context);
if(intent.getExtras().getString("origin").equals("helpshift")) {
PendingIntent intent = hs.getPendingIntentOnPush(context, i);
}
int icon = R.drawable.notif_icon;
Bundle extras = i.getExtras();
String message = extras.getString("alert");
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}| c | The recieved context |
|---|---|
| intent | The recieved intent |
Installs the Helpshift Android SDK in your app.
hs.install(this,
"<YOUR_API_KEY>",
"<yourcompany>.helpshift.com",
"<YOUR_APP_ID>");| activity | The context of you main launcher activity |
|---|---|
| apiKey | Your developer API Key |
| domain | Your domain name without any http:// or forward slashes |
| appId | The unique ID assigned to your app |
This is used to find out if the Helpshift issues chat screen is in the foreground. Can be used to conditionally show/disable notifications when chat is shown. This can be done by implementing your own PushNotificationBuilder. For Example:-
public Notification buildNotification(String alert, Mapextras) { Context c = UAirship.shared().getApplicationContext(); if(!hs.isForeground()) { return super.buildNotification(alert, extras); } else { return null; } }
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 reported the issue.
hs.leaveBreadCrumb("Went to Preferences Screen");| breadCrumb | Action/Message to add to bread-crumbs list. |
|---|
(Optional) If you already have unique indentification for your users, you can specify that as well. For example:
hs.setDeviceIdentifier("user-id-100");| deviceId | A custom user Identifier. |
|---|
If you are using 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:-
String action = intent.getAction();
if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
hs.setDeviceToken(PushManager.shared().getAPID());
}| deviceToken | This is the Android Push ID (APID) |
|---|
(Optional) you can configure or pre-define certain user information. Provided you have that information, so that the user does not have to provide their information again. For example:
hs.setEmail("john@helpshift.com");| User email. |
Provide a function to fetch custom data.
import com.helpshift.HSCallable;
k.put ("hello", "world");
k.put ("foo", "bar");
hs.setMetadataCallback (new HSCallable (){
public HashMap call() {
return k;
}
});
| f | HSCallbale object with call method implemented. |
|---|
(Optional) you can configure or pre-define certain user information. Provided you have that information, so that the user does not have to provide their information again. For example:
hs.setUsername("John");| name | User name. |
|---|
Shows faqs activity. This will show list of sections with search.
showFaqsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showFaqs(MyActivity.this);
}
});
| a | The Activity from which you call show faqs activity. |
|---|
Shows faqs activity. This will show list of sections with search.
showFaqsBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("showConvOnReportIssue", true);
config.put("showReportIssue", true);
hs.showFaqs(MyActivity.this, config);
}
});
There are two flags supported in config.
- showConvOnReportIssue (Default : false) If set to true.
Helpshift SDK will land on conversation activity after reporting an issue.
If set to false Helpshift SDK will land on last activity before report issue.
- showReportIssue (Default : true) If set to true it will show report issue button.
If set to false it will hide report issue button.| a | The Activity from which you call show faqs activity. |
|---|---|
| config | Extra config. |
Shows issues inbox activity. This will render a view with list of issues. For example, this can be triggered on the onClick of inboxBtn Button
inboxBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showInbox(MyActivity.this);
}
});
| a | The Activity from which you call show inbox activity. |
|---|
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 showQuestionBtn Button.
showQuestionBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showQuestion(MyActivity.this, "1");
}
});
| a | The Activity from which you call show question activity. |
|---|
Shows report issue activity. This provides a direct call to the "Report new issue" activity. For example, this can be triggered on the onClick of "Report Issue" Button
reportIssueBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showReportIssue(MyActivity.this);
}
});
| a | The Activity from which you call Report new issue activity. |
|---|
Shows report issue activity. This provides a direct call to the "Report new issue" activity. For example, this can be triggered on the onClick of "Report Issue" Button
reportIssueBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.put("showConvOnReportIssue", true);
hs.showReportIssue(MyActivity.this, config);
}
});
There are two flags supported in config.
- showConvOnReportIssue (Default : false) If set to true.
Helpshift SDK will land on conversation activity after reporting an issue.
If set to false Helpshift SDK will land on last activity before report issue.| a | The Activity from which you call Report new issue activity. |
|---|---|
| config | Extra config. |
Shows section activity. This will show a 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 showSectionBtn Button
showSectionBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showSection(MyActivity.this, "1");
}
});
| a | The Activity from which you show section activity. |
|---|---|
| sectionPublishId | Id specifying a section. |
Calls the main support screen. For example, this can be triggered on the onClick of a "Help" button.
helpBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
hs.showSupport(MyActivity.this);
}
});| a | The Activity from which you call support. |
|---|
Calls the main support screen. For example, this can be triggered on the onClick of a "Help" button.
helpBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
HashMap config = new HashMap ();
config.putExtra("showConvOnReportIssue", true);
hs.showSupport(MyActivity.this, HashMap config);
}
});
There is one flag supported in config.
- showConvOnReportIssue (Default : false) If set to true.
Helpshift SDK will land on conversation activity after reporting an issue.
If set to false Helpshift SDK will land on last activity before report issue.| a | The Activity from which you call support. |
|---|---|
| config | Extra config. |
To show Helpshift support on Notification opened, call showSupportOnPush in your IntentReceiver for Handling of Push Events. Check that the origin is "helpshift" before calling showSupportOnPush. For Example:-
String action = intent.getAction();
if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
if(intent.getExtras().getString("origin").equals("helpshift")) {
hs.showSupportOnPush(intent);
}
}| intent | The recieved intent |
|---|
Starts poller for fetching notification count asynchronously by implementing the countHandler and failHandler. Polling interval needs to be specified in seconds. The minimum you can specify is 3 seconds.
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);
}
}
};
@Override
public void onResume() {
super.onResume();
hs.startNotifCountPolling(countHandler, failHandler, 3);
}| success | Success handler |
|---|---|
| failure | Failure handler |
| interval | Interval integer |
Starts poller for fetching notification count asynchronously by implementing the countHandler and failHandler. The polling interval is 10 seconds. 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);
}
}
};
@Override
public void onResume() {
super.onResume();
hs.startNotifCountPolling(countHandler, failHandler);
}| success | Success handler |
|---|---|
| failure | Failure handler |
Stops poller for fetching notification count.
@Override
public void onPause() {
super.onPause();
hs.stopNotifCountPolling();
}