public class

Core

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

Class Overview

Helpshift Core API provider

Summary

Public Constructors
Core()
Public Methods
static void clearAnonymousUser()
Delete the default user data and generate new default user If any Support session is active, then clearAnonymousUser attempt is ignored in support sdk.
static void handlePush(Context context, Map<StringString> data)
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, InstallConfig config)
Installs the Helpshift Android SDK in your app with Config.
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<StringObject> config)
This method is deprecated. As of release 6.0.0, use install(Application, String, String, String, InstallConfig) instead.
static void login(String userId, String name, String email)
Login a user with a given user identifier, name and email.
static void login(HelpshiftUser helpshiftUser)
Login a user with a given identifier or email in HelpshiftUser This API introduces support for multiple login in Helpshift SDK.
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.
static void setSDKLanguage(String locale)
Set the SDK language for the given locale.
static void setTheme(int themeResourceId)
Sets the SDK theme.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Core ()

Public Methods

public static void clearAnonymousUser ()

Delete the default user data and generate new default user If any Support session is active, then clearAnonymousUser attempt is ignored in support sdk.

public static void handlePush (Context context, Map<StringString> data)

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, InstallConfig config)

Installs the Helpshift Android SDK in your app with Config.

 InstallConfig.Builder configBuilder = new InstallConfig.Builder();
 configBuilder.setNotificationIcon(R.drawable.megaphone);
 configBuilder.setLargeNotificationIcon(R.drawable.app_icon);
 configBuilder.setNotificationSound(R.raw.custom_notification);
 configBuilder.setEnableDefaultFallbackLanguage(preferences.getBoolean("enableDefaultFallbackLanguage", true));
 InstallConfig config = configBuilder.build();
 

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

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 InstallConfig object to configure the SDK.
Throws
InstallException

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.
Throws
InstallException

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

This method is deprecated.
As of release 6.0.0, use install(Application, String, String, String, InstallConfig) instead.

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.
Throws
InstallException

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 login (HelpshiftUser helpshiftUser)

Login a user with a given identifier or email in HelpshiftUser This API introduces support for multiple login in Helpshift SDK. The user uniquely identify via identifier and email combination. If any Support session is active, then any login attempt for support sdk is ignored.

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. If you want to reset both values, you should pass null for both params. NOTE: This API will not update the name & email provided from login API. Data from this API will be used to pre-fill name and email fields in the conversation form.

For example:

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

Parameters
name User name
email User email

public static void setSDKLanguage (String locale)

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.

 Support.setSDKLanguage("fr");
 

Example - Setting the SDK language for the given locale with both language code and country code.

 Support.setSDKLanguage("zh_CN");
 

Parameters
locale locale contains either language code or both language code and country code.

public static void setTheme (int themeResourceId)

Sets the SDK theme. This will set theme for all the SDK screens. Passing an invalid resource value here would reset the theme and the default Helpshift theme would be picked.



Example - Setting SDK theme for the given theme resource id.

 Core.setTheme(R.style.Custom_Theme);
 

Example - Resetting SDK theme

 Core.setTheme(-1);
 

Parameters
themeResourceId Resource ID of the theme to set