public class

Core

extends Object
java.lang.Object
   ↳ com.helpshift.Core

Summary

Public Constructors
Core()
Public Methods
static void handlePush(Context context, Bundle data)
static void handlePush(Context context, Intent intent)
This will handle push received from Helpshift using either GCM push or Urban Airship.
static void init(Core.ApiProvider apiProvider)
Initialize the Core class with the Helpshift service that you want to use.
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 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 setNameAndEmail(String name, String email)
(Optional) You can specify the name and email for your User.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Core ()

Public Methods

public static void handlePush (Context context, Bundle data)

public static void handlePush (Context context, Intent intent)

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")) {
 Core.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")) {
 Core.handlePush(context, intent);
 }
 }
 }

Parameters
context The received context.
intent The received intent.

public static void init (Core.ApiProvider apiProvider)

Initialize the Core class with the Helpshift service that you want to use. Currently helpshift supports following three apiProviders : 1. Support 2. Campaigns 3. All

For example:

 Core.int(All.getInstance());

public static void install (Application application, String apiKey, String domain, String appId)

Installs the Helpshift Android SDK in your app.

 Core.install(getApplication(),
 "<YOUR_API_KEY>",
 "<yourcompany>.helpshift.com",
 "<YOUR_APP_ID>");

Parameters
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.

public static void install (Application application, String apiKey, String domain, String appId, Map config)

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);
 

Core.install(getApplication(), "<YOUR_API_KEY>", "<yourcompany>.helpshift.com", "<YOUR_APP_ID>", config);

There are four values supported in this config -

  1. notificationIcon (Default : None) - You can set this value to a resource drawable which will be used as a custom icon when showing notifications.
  2. enableInAppNotification (Default : true) - when set to false; this will disable the Helpshift SDK in-app notifications poller service.
  3. notificationSound (Default : None) - you can set this value to a raw resource of audio type (.mp3/.wav etc.) which will be used as custom sound when showing notifications.
  4. enableDialogUIForTablets (Default : false) - when set to true; Helpshift SDK will be opened in Dialog mode on tablet devices.
  5. enableDefaultFallbackLanguage (Default : true) - when set to false; the Helpshift SDK will not fallback to the default language when showing FAQ. Use this if you intend to have FAQ in multiple languages but do not want to fallback to ‘English’ FAQ.

Parameters
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.

public static void login (String userId, String name, String email)

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 Support session is active, then any login attempt for support sdk is ignored.

Parameters
userId The unique identifier of the user.
name (Optional) The name of the user.
email (Optional) The email of the user.

public static void logout ()

Logout a currently logged in user. After logout, Helpshift falls back to the default login. If any Support session is active, then any logout attempt is ignored in support sdk.

public 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. 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); Core.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();
 Core.registerDeviceToken(context, regId);
 }
 }

Parameters
context The received context.
deviceToken This is the Android Push ID (APID)

public static void setNameAndEmail (String name, String email)

(Optional) You can specify the name and email for your User.

For example:

 Core.setNameAndEmail("John", "john@example.com");

Parameters
name User name
email User email