Getting Started
Getting Started
Prerequisites
Before starting the integration of the Zendesk SDK, please ensure that the following prerequisites are fulfilled.
Supported Unity versions
Supported versions: 2020 LTS, 2021 LTS and 2022 LTS.
Supported Android & iOS versions
Our SDK is designed to seamlessly integrate with Unity's supported platforms, optimizing both integration and performance. To maximize the features offered by our SDK, ensure that your version of Unity aligns with the required operating system version for Android and iOS.
Checking your account requirements
You must have a Zendesk account with messaging enabled. See Checking your account requirements for information.
Adding the Zendesk SDK for Unity package
Adding a scoped registry
In the Unity Editor, click Project Settings > Package Manager and expand the Scoped Registries group.
Enter the following registry details and click Save.
Name: Zendesk
URL: https://zendesk.jfrog.io/artifactory/api/npm/unity-sdk
Scopes: com.zendesk.messaging
Installing the Zendesk SDK for Unity package
In the Unity Editor, open the Package Manager by selecting Window > Package Manager. Browse or search for Zendesk SDK for Unity package, select it from the list, and then click Install. For more information, see the Package Manager window documentation.
Installing Sample scenes
To install samples, select Import next to the desired sample in the package details tab.
Dependencies
Please consult the list of dependencies used in our SDK.
Note on Newtonsoft.Json dependency
Our SDK uses Newtonsoft.Json and maintains compatibility with Unity's fork. For more information, see Newtonsoft Json Unity Package.
Obtain a channel id from Zendesk's Admin Center
Before you initialize your SDK, you'll need to obtain a channel id. The channel id is a unique identifier that the SDK requires to initialize correctly. You can obtain it from the Zendesk Admin Center. For instructions, see Working with messaging in the Zendesk SDKs for Android and iOS. If you're not a Zendesk admin on your account, ask one to get it for you.
Initialize the SDK
-
Add the following import to your project:
C#
using Zendesk.Runtime.SDK;
-
Call
await ZendeskSdk.InitializeAsync(config => config.ChannelId = "channelId");
.Optional parameters:
Language
: Language of the SDK of type "ZendeskLanguage". If not set, it defaults to the device language.
C#
await ZendeskSdk.InitializeAsync(config =>
{
config.ChannelId = "channelId";
config.Language = ZendeskLanguage.English;
});
Show the conversation
-
Call the
ShowMessagingAsync()
method from theZendeskSdk.Instance.Messaging
instance.Optional parameters:
parentTransform
: Parent transform that the Zendesk prefab will be child of, or null (zendesk prefab will be instantiated at the root of the first canvas).
C#
await ZendeskSdk.Instance.Messaging.ShowMessagingAsync();
Once ShowMessagingAsync()
is called, the Zendesk Messaging UI is displayed.
Troubleshooting
Logging
If you have difficulty getting started, or want to see more detailed information from the SDK, enable logging using the following C# code:
using Zendesk.Runtime.Logging;
ZendeskLogger.SetEnabled(true);
You can check the state of the Logger by using:
ZendeskLogger.IsLogEnabled();
IL2CPP Stripping
If you are using IL2CPP, you may be using the Managed Stripping Level property to decrease the size of your app.
The Zendesk SDK functions as expected with Managed Stripping Level set to minimum
. If you set it to any other level, you must include a link.xml file in the Unity Assets folder with the following contents. Otherwise, your code may throw unexpected errors and exceptions.
<linker>
<assembly fullname="Unity.Zendesk" preserve="all"/>
<assembly fullname="Unity.Zendesk.MessagingCore" preserve="all"/>
</linker>
The above code disables stripping for the Zendesk SDK assemblies.
Common Errors
CS1069: The type name 'AndroidJavaProxy' could not be found in the namespace 'UnityEngine'. This type has been forwarded to assembly 'UnityEngine.AndroidJNIModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Enable the built in package 'Android JNI' in the Package Manager window to fix this error.
This error occurs when the Unity Editor Build Target is set to Android, but the necessary Android JNI package is not included in the project.
Solution:
- Open the Unity Editor.
- Navigate to Window > Package Manager.
- Look for the 'Android JNI' or
com.unity.modules.androidjni
package. - Enable the package to include it in your project.
Ensure that the project includes all required packages as listed in our Dependencies Documentation.
CS1061: 'Texture2D' does not contain a definition to 'EncodeToJPG' and no accessible extension method 'EncodeToJPG' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?)
Solution:
This error requires UnityWebRequestTexture
package to be present in the project. See Dependencies to ensure all required packages are present.
Next Steps
Once you complete the above steps, you are now in good shape to explore the SDK and understand how messaging will work for your business and your end users.