You're 3 steps away from adding great in-app support to your Unity game.
Guide to integrating the Unity plugin for the Helpshift SDK which you can call from your C# and Javascript game scripts.
Helpshift SDK .zip folder includes:
We recommend you to upgrade to the latest SDK as mentioned above. However, if you are currently using Unity SDK 4.x and need more details, click here.
Only for SDK versions 5.5.4 and below -
In case you want to use the SDK with bitcode support, keep Bitcode
folder selected and deselect Helpshift.framework
while importing Helpshift unitypackage.
.unitypackage
which you can import through the Unity package import procedure.helpshift-plugin-unity-version.unitypackage
into your Unity game:Assets/Helpshift
folder from your unity project.helpshift-plugin-unity-version.unitypackage
file to import the Helpshift SDK.After importing the Helpshift unitypackage file, you may see errors like:
Assets/Helpshift/Plugins/iOS/Helpshift.framework/HsUIResourceBundle.bundle/*.png: File could not be read
.
These errors are shown by Unity because Apple converts traditional PNG images to a optimised CgBI format using a proprietary version of the public domain pngcrush tool making the file different from the PNG standards.
This optimisation reduces the size of PNG image by almost half, making our asset folder very small in size.
Unity is not able to read these images hence throws error like File could not be read
.
Please ignore the import errors as they will be seen only once while importing and will not cause any run time issues.
If you are using Xcode 12.3 or above to build your project, please make sure you follow the step mentioned here in troubleshooting guide.
To use Helpshift's APIs, please import the Helpshift's namespace for iOS like below
using Helpshift;
Helpshift can be used to support all the apps you publish. We uniquely identify each app that is registered with Helpshift using the combination of:
To get the API Key
, Domain Name
and the App ID
, navigate to Settings
>SDK (for Developers)
in your agent dashboard and scroll down to "Initializing Helpshift" section. show me
Select your App from the dropdown and copy the three tokens to be passed when initializing Helpshift.
You can use the CSharp API for installing the Helpshift SDK.
using Helpshift; . . . public class MyGameControl : MonoBehaviour { private HelpshiftSdk help; ... void Awake() { help = HelpshiftSdk.getInstance(); var configMap = new Dictionary<string, object>(); help.install("<API_KEY>", "<DOMAIN_NAME>", "<APP_ID>", configMap); } ... }
If you intend to initialize the SDK from Xcode using Objective C, You can specify Api Key, Domain Name, App 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 <Helpshift/HelpshiftCore.h> #import <Helpshift/HelpshiftSupport.h> #import "Helpshift-Unity.h" . . - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Set install configurations NSDictionary *installConfig = @{@"unityGameObject":@"background_image", @"enableInAppNotification":@"yes"}; // Make install call [HelpshiftCore initializeWithProvider:[HelpshiftSupport sharedInstance]]; [HelpshiftCore installForApiKey:@"<your_api_key>" domainName:@"<your_domain_name>.helpshift.com" appID:@"<your_app_id>" withOptions:installConfig]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; }
In order to receive callbacks from Helpshift, you must pass a valid game object for unityGameObject key in the install configuration.
For its internal functioning, Helpshift needs to override below mentioned functions of UIApplicationDelegate
protocol. The class HsUnityAppController
overrides these functions as required. These methods are called by external iOS services and expect the application to call completionHandler(). By default, UnityAppController class does not implement these functions. If you require any of these functions or other features of your app, you must override these functions, comment out or remove default completionHandler() call and provide your own implementation as per your requirements.
- (void) application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler { if (![HelpshiftCore handleEventsForBackgroundURLSession:identifier completionHandler:completionHandler]) { // Handle events for background url session. Once you have implemented this function in UnityAppController, uncomment // the code below and comment the call completionHandler(); //[super application:application handleEventsForBackgroundURLSession:identifier completionHandler:completionHandler]; completionHandler(); } } - (void) application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler { if (![HelpshiftCore handleInteractiveRemoteNotification:userInfo forAction:identifier completionHandler:completionHandler]) { // Handle action with identifier. Once you have implemented this function in UnityAppController, uncomment // the code below and comment the call completionHandler(); //[super application:application handleActionWithIdentifier:identifier forRemoteNotification:userInfo completionHandler:completionHandler]; completionHandler(); } } - (void) application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { if(![HelpshiftCore handleInteractiveLocalNotification:notification forAction:identifier completionHandler:completionHandler]) { // Handle action with identifier. Once you have implemented this function in UnityAppController, uncomment // the code below and comment the call completionHandler(); //[super application:application handleActionWithIdentifier:identifier forLocalNotification:notification completionHandler:completionHandler]; completionHandler(); } }
Helpshift is now integrated in your app. You should now use the support APIs to present FAQ or conversation screens inside your app.
Run your app, and try starting a test conversation using the showConversation
API call.
Then goto your Helpshift agent dashboard and reply to experience the in-app messaging.
Sample usage for FAQs and conversation APIs:
public class MyGameControl : MonoBehaviour { private HelpshiftSdk help; void OnGUI () { ... Dictionary<string, object> configMap = new Dictionary<string, object>(); // Presenting FAQs to your customers if (MenuButton (helpButton)) { help.showFAQs(configMap); } // Starting a conversation with your customers if (MenuButton (contactButton)) { help.showConversation(configMap); } } }
Since the Helpshift plugin is meant for mobile devices only, you should put all Helpshift calls inside checks to make sure they are only called when running on a device. / #run-on-device /