ImportantBefore you can use any other functions of the SDK, you must initialize it by calling the
initialize() method.Initialization
initialize
initialize() method initializes the SDK with the given token and domain. Additionally, you need to pass an options argument and tell whether you want to use the SDK in game or widget mode.
If you are running the SDK in-game, use the game mode and if you are running it on your website, use the widget mode.
InitializeGameOptions
InitializeWidgetOptions
Opening and closing
openSupport
openSupport() method opens the help center.
TheymesConfig can optionally be used to customize the help center. See Configuring the SDK for more information.
openResource
resource argument from Theymes application, for example openResource("crafting-guide").
TheymesConfig can optionally be used to customize the resource. See Configuring the SDK for more information.
openAssistant
TheymesConfig can optionally be used to customize the resource. See Configuring the SDK for more information.
close
openResource(). Normally you don’t need to call this method, as the player will see a close button in the SDK UI, but if you need to close the resource programmatically, you can use this method.
Notifications
Notifications can be shown to user when there’s a new message in their open tickets. Typically you would call
enableNotifications() when transitioning to game menus or other screens where the player is not actively playing, and disableNotifications() when transitioning to gameplay.Notifications are disabled by default and widget mode does not support notifications.enableNotifications
disableNotifications
Config
getLanguage
null if no language is set.
setLanguage
getPlayer
null if no player information is set. See Configuring the SDK for more information about the TheymesPlayer object.
setPlayer
getSignedMetadataToken
setSignedMetadataToken
Tags
Tags can be used to send additional information to Theymes. The tag must be configured in the Theymes application first or otherwise it will be ignored.getTags
setTags
addTag
addTags
removeTag
removeTags
removeAllTags
Breadcrumbs
Breadcrumbs are short diagnostic messages that are timestamped automatically and sent when opening support or a resource. They are kept in memory only and are cleared byclearBreadcrumbs() and reset().
addBreadcrumb
addBreadcrumbs
clearBreadcrumbs
Fields
Fields are a set of key-value pairs that can be used to send additional information to Theymes. The field must be configured in the Theymes application first or otherwise it will be ignored. The value type for the fields isobject, but accepted values are booleans, strings, numbers and lists of strings. The type must match the type configured in Theymes or it will be ignored.
getFields
setFields
addField
addFields
removeField
removeFields
removeAllFields
Privacy
isYoungPlayer
true if the player is set as a young player, otherwise false.
setYoungPlayer
Setting the player as a young player will also enable the privacy mode, you do not need to call
setPrivacyMode(true) separately. Additionally support agents will see that they are talking to a young player and can handle the conversation accordingly.isPrivacyMode
true if the privacy mode is enabled, otherwise false.
setPrivacyMode
Other
true if the help center is supported on the current platform, otherwise false.
getSdkVersion
reset
getUnreadMessageCount
getUnansweredMessageCount
iosSetKeyboardHeight
0 for hidden). Theymes SDK will re-layout its view if present to make sure that the keyboard is not blocking any text inputs users are writing to.
You generally never need to use this. This is only needed in special situations when embedding Theymes SDK inside an app wrapper such as Cordova and if you are overriding the default behavior of iOS keyboard to allow hiding your web page content under the keyboard.
Events
There are five different events Theymes currently supports. You can add and remove event listeners by callingaddEventListener and removeEventListener with a listener function for each event type.
You can use the events to update your game’s or web page’s UI (e.g. to show a badge or indicator for unread or unanswered messages).
addEventListener
signedMetadataTokenExpirationUpdate event is called only when a signed metadata token is set. It is called immediately when the page comes to the foreground and then once a minute while the page stays in the foreground. The listener receives the remaining expiration time in seconds. If the token is already expired, the value is 0 or negative. Your game or page decides when to refresh the token based on this value. The value is calculated from the client’s clock, so if the clock is not in sync, the reported expiration time is skewed too.
removeEventListener
removeEventListener must be the same function reference which was passed to addEventListener.