Getting started with integrating Helpshift in your Unity app.
Guide to integrating the Unity plugin for the Helpshift SDK which you can call from your C# and Javascript game scripts.
HelpshiftX SDK .zip folder includes:
.unitypackage
which you can import through the Unity package import procedure.helpshiftX-plugin-unity-version.unitypackage
into your Unity game:helpshiftX-plugin-unity-version.unitypackage
file to import the Helpshift SDK.“User Attachments” feature is enabled for SDK which allows User to upload an attachment. The attachments can be picked from the Photo Library or can be captured directly using the camera. The options for these sources look like:
To use the camera and photo library, Apple requires the app to have Usage Description strings in the Info.plist while. Failing to add these strings might result in app rejection. The following strings are needed for the attachment feature:
Key | Suggested string | Notes |
---|---|---|
NSPhotoLibraryUsageDescription | “We need to access photos library to allow users manually pick images meant to be sent as an attachment for help and support reasons.” | This is not needed if your app is iOS 11 or above. Below iOS 11, this key is compulsory else the app may crash when user tries to open the photo library for attaching photos. |
NSCameraUsageDescription | “We need to access the camera to allow users to click images meant to be sent as an attachment for help and support reasons.” | This key is needed for capturing a photo using camera and attaching it. |
NSMicrophoneUsageDescription | “We need to access the microphone to allow users to record videos using camera meant to be sent as an attachment for help and support reasons.” | This key is needed for capturing a video using camera and attaching it. |
End-users can attach files such as pdf, video, etc in their issues. For iOS 10 and below, to access files in the “Files” app of iOS, developers will need to add iCloud capability with iCloud Documents services enabled. For more info please refer the Prerequisites section here. show me
To use Helpshift's APIs, please import the Helpshift's namespace like below
using Helpshift;
Helpshift uniquely identifies each registered App with a combination of 2 tokens:
Domain Name
Platform ID
Settings
>SDK (for Developers)
in your agent dashboard.
Select your App and check webchat as a platform from the dropdowns and copy
the 2 tokens to be passed when initializing Helpshift.
show me
Initialize Helpshift by calling the method install(platformId, domain) API
using Helpshift; . . . public class MyGameControl : MonoBehaviour { private HelpshiftSdk help; ... void Awake() { help = HelpshiftSdk.GetInstance(); var configMap = new Dictionary<string, object>(); help.Install(platformId, domainName, configMap); } ... }
If you intend to initialize the SDK from Xcode using Objective C, You can specify Domain Name, Platform ID and other install configurations in the Objective-C code. To do this you need to override application:didFinishLaunchingWithOptions
in HsUnityAppcontroller
as shown below.
#import <HelpshiftX/HelpshiftX.h> #import "HelpshiftX-Unity.h" - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Set install configurations NSDictionary *installConfig = @{@"enableInAppNotification":@YES}; // Make install call [Helpshift installWithPlatformId:@"<your_platform_id>" domain:@"<your_domain_name>" config:installConfig]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; }
You can use the API call ShowConversation(configMap)
to allow a user to directly send feedback. Once, a user starts a new conversation, this API call will show the conversation screen. The conversation will continue until it is resolved or rejected by the agent.
To configure the conversation screen, you can pass various config options in a Dictionary<string, object>
. It is advised to add Initial User Message in the configMap
.
Example :
using Helpshift; private HelpshiftSdk help; // install call here void Awake(){ help = HelpshiftSdk.GetInstance(); help.Install(platformId, domainName, null); } // configuration map Dictionary<string, object> configMap = new Dictionary<string, object> { { "tags", new String[] { "foo", "bar" } }, { "initialUserMessage", "Give Feedback"} }; // open the support chat screen help.ShowConversation(configMap);
You can use the API call ShowFAQs(configMap)
to provide a way for the user to invoke the purpose-built help/FAQs section in your app. This is the easiest approach to enable help in your app as it bundles all the capabilities of the Helpshift SDK in a simple and intuitive interface. You can wire this API call to a "Help" or "FAQs" action in your app.
To configure the FAQs screen, you can pass various config options in a Dictionary<string, object>
. It is advised to add Initial User Message in the configMap
.
Example :
using Helpshift; private HelpshiftSdk help; // install call here void Awake(){ help = HelpshiftSdk.GetInstance(); help.Install(platformId, domainName, null); } // configuration map Dictionary<string, object> configMap = new Dictionary<string, object> { { "tags", new String[] { "foo", "bar" } }, { "initialUserMessage", "Give Feedback"} }; // open the FAQs screen help.ShowFAQs(configMap);
If you want to add Custom Metadata at the time of Issue creation, follow the steps.
Map
Map
Map
Map
to the top-level Map
Map
to configMap
with key "customMetadata"
to any of the SDK APIs (like ShowConversation(configMap)
).Dictionary<string, string> customMetadataMap = new Dictionary<string, string>(); customMetadataMap.Add("Level", "9"); customMetadataMap.Add("Spend", "46.55 USD"); customMetadataMap.Add("Device Timestamp", DateTime.UtcNow.ToLongTimeString()); Map<String, Object> config = new HashMap<>(); // other configs... //.. config.put("customMetadata", customMetadataMap); Helpshift.showConversation(MainActivity.this, config);
Metadata should only be sent as String key-value pairs.
Dictionary<string, string> customMetadataMap = new Dictionary<string, string>(); Map<String, Object> config = new HashMap<>(); // other configs... //.. config.put("customMetadata", customMetadataMap); Helpshift.showConversation(MainActivity.this, config);
On Custom Issue Fields keys & compatibility
If you want to set Custom Issue Fields at the time of Issue creation, follow the steps.
Dictionary
Dictionary
"type"
and "value"
for that custom issue fieldconfigMap
with key "customIssueFields"
of the ShowConversation(configMap)
Dictionary<string, object> joiningDate = new Dictionary<string, object>(); joiningDate.Add("type", "date"); joiningDate.Add("value", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()); Dictionary<string, string> stockLevel = new Dictionary<string, string>(); stockLevel.Add("type", "number"); stockLevel.Add("value", "1505"); Dictionary<string, string> employeeName = new Dictionary<string, string>(); employeeName.Add("type", "singleline"); employeeName.Add("value", "Bugs helpshift"); Dictionary<string, string> isPro = new Dictionary<string, string>(); isPro.Add("type", "boolean"); isPro.Add("value", "true"); Dictionary<string, object> cifDictionary = new Dictionary<string, object>(); cifDictionary.Add("joining_date", joiningDate); cifDictionary.Add("stock_level", stockLevel); cifDictionary.Add("employee_name", employeeName); cifDictionary.Add("is_pro", isPro); Map<String, Object> config = new HashMap<>(); // other configs... //.. config.put("customIssueFields", cifMap); Helpshift.showConversation(MainActivity.this, config);
The following are the valid values for the type
key of a Custom Issue Field.
Compatibility table for type and values:
Type | Value | Comments |
---|---|---|
singleline | string | Character limit of 255 |
multiline | string | Character limit of 100,000 |
number | string | |
dropdown | string | Drop-down options should exist for the given Custom Issue Field |
date | number | Epoch time in milliseconds. For example - DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() |
checkbox | boolean |