Helpshift Delegates
The Helpshift SDK provides delegate callbacks to help app developers track a user's activities within the help section.
All delegate callbacks will be registered and called with function pointers with matching signatures.
Helpshift Session delegates
Session begin
helpshiftSessionBegan
If you want to keep track of when helpshift session starts in your app, you can implement this delegate callback. The delegate will get fired every time the Helpshift session starts.
Session end
helpshiftSessionEnded
If you want to keep track of when helpshift session ends in your app, you can implement this delegate callback. The delegate will get fired every time the Helpshift session ends.
For example:
void hsSessionBegun() {
CCLOG("Helpshift Session began");
}
void hsSessionEnded() {
CCLOG("Helpshift Session ended");
}
.
.
.
HelpshiftCocos2dx::registerSessionDelegates(hsSessionBegun, hsSessionEnded);
Conversation delegates
New Conversation Started
newConversationStarted
If you want to keep track of when your app users start a new conversation through Helpshift, you can implement this delegate callback . The delegate will get fired every time the user starts a new conversation. The delegate method will receive the conversation message in it's arguments.
As soon as an end user opens the conversation screen, they will see a greeting message, and the conversation is considered active.
New message delegate
userRepliedToConversation
If you want to keep track of when your app users send new messages to an ongoing conversation, you can implement this delegate. This delegates will get called every time a user replies to a conversation. The delegate method will receive the new message's content in it's arguments. if the message is of a special type then it will be one of the following four messages.
#define HS_USER_ACCEPTED_SOLUTION "User accepted the solution"
#define HS_USER_REJECTED_SOLUTION "User rejected the solution"
#define HS_USER_SENT_SCREENSHOT "User sent a screenshot"
#define HS_USER_REVIEWED_APP "User reviewed the app"
All replies from end users to your Bots (QuickSearch Bot, Identity Bot) are also considered as new messages added by end users.
Customer satisfaction survey delegate
userCompletedCustomerSatisfactionSurvey
If you want to keep track of when your app user completes the customer satisfaction survey for a conversation, you can implement this delegate. This delegates will get called every time a user completes the customer satisfaction survey. The delegate method will receive the rating and the feedback in it's arguments.
New message received count delegate
didReceiveNotification
If you want to keep a count of all new messages recieved in an existing conversation, you can implement this delegate. This delegate will get called with the current unread count every time when helpshift recieves a new message in an existing conversation. You can also use this delegate to keep your badge counts updated.
Conversation Ended
conversationEnded
This delegate callback can be implemented to check if an ongoing Conversation has ended. This delegate is called whenever the ongoing Conversation is resolved, rejected from the Dashboard, timed out or archived.
For example:
void newConversationHandler (const char *message) {
CCLOG("New conversation started with message : %s", message);
}
void newConversationMessageHandler (const char *message) {
CCLOG("New conversation message : %s", message);
}
void csatHandler (int rating, const char *feedback) {
CCLOG("CSAT with rating : %d and feedback %s", rating, feedback);
}
void didReceiveNotification (int count) {
CCLOG("Notification Count : %d ", count);
}
void conversationEnded() {
CCLOG("Conversation Ended");
}
.
.
.
HelpshiftCocos2dx::registerConversationDelegates(newConversationHandler,
newConversationMessageHandler,
csatHandler,
notificationHandler,
conversationEnded);
Display attachment delegate
Agents can attach a wide variety of files when replying to users. Following types of file formats are currently supported:
- Video files (3gp, m4v)
- Audio files (mp3, mp4, aac)
- Image files (jpg, png, gif)
If your application wants to handle a certain file type in a custom way, the application should register the file extension with Helpshift in the config dictionary passed to the install call.
Example
HashMap config = new HashMap();
String[] fileFormats = new String[]{"token"};
config.put("supportedFileFormats", fileFormats);
HelpshiftBridge.install(this, "apikey",
"domain.helpshift.com",
"appId",
config);
The application also needs to register the function which will be called when the Helpshift SDK detects a file with the registered file extension.
static void registerDisplayAttachmentDelegate (void (*displayAttachmentListener)(const char *filePath));
After the attachment is downloaded, Helpshift checks for any app which can open it. If no such app is found, then we fall back to passing the file to the delegate handler in the app. There are two possible variants of the path parameter in HandleTapOnAttachmentFile(string path), one is FilePath and the other one is Uri.
- On Android version 10 & above, path value will be a
Uri
path because Files are exposed with Uri objects by the OS. - On Android versions older than 10, path value will the
File
path
void displayAttachmentListener(const char *filePathOrUri) {
char uriPrefixString[] = "content://";
int result = std::strncmp(filePathOrUri, uriPrefixString, strlen(uriPrefixString));
if(result == 0) {
// your code here to handle uri
} else {
// your code here to handle filePath
}
}
Authentication failure delegate
If identity verification fails, the SDK will invoke one of the following delegates to notify the application of the failure:
Delegate | When is it called | When to use |
---|---|---|
HSAuthTokenNotProvided | When no 'user authentication token' is provided | If you do not plan on sending a 'user authentication token' when implementing Cocos2d-x SDK 4.0.0, but plan on implementing it in the future, you can use this failure delegate to show your own alerts to the user, such as a prompt to update the app. You may want to use this if you are using the login API without the 'user authentication token', since these users will be considered unverified once 'Identity Verification' is enabled on the Dashboard. Using this delegate is completely optional - Helpshift will prevent unverified users from being able to file Issues, as mentioned previously. |
HSInvalidAuthToken | When the 'user authentication token' is invalid | For Cocos2d-x SDK v4.0.0 and later, if the HMAC Digest being provided via login API is invalid, then Helpshift will prevent the users from filing Issues. The 'user authentication token' can be invalid if:
|
void authenticationFailure(HelpshiftCocosUser *user, HSAuthenticationFailureReason reason) {
if (reason == HSAuthenticationFailureReason::HSAuthTokenNotProvided) {
...
} else if (reason == HSAuthenticationFailureReason::HSInvalidAuthToken) {
...
}
}
HelpshiftCocos2dx::registerAuthenticationFailureDelegate(authenticationFailure);
User click on action delegate
This delegate method is called when the user clicks on the action in Action Card bot.
actionType | The type of action user clicked on. Can be one of: HSActionTypeCall, HSActionTypeLink |
actionData | The data associated with the action type. Can be a url link or a phone number. |
For example:
void onActionCardClicked(HSActionType actiontype, const char *actionData) {
if(actionType == HSActionType::HSActionTypeCall) {
...
} else if(actiontype == HSActionType::HSActionTypeLink) {
...
}
}
HelpshiftCocos2dx::registerActionCardDelegate(onActionCardClicked);