# Events
We'll broadcast several events on the fly. You can subscribe to the relevant events to handle your own logic.
Note
All callbacks for subscribed events will be executed in a background thread. Please be cautious when manipulating UI elements.
# API
# registerAsyncEventListener()
To register a callback for a specific event.
void listener(const char *jsonData, void (*acknowledge)(const char *jsonAckData)) {
// You can get callback here if the target event is fired
// checkout at the definition and code examples for more information
}
[AIHelpSupportSDK registerAsyncListener:listener eventType:YOUR_EVENT];
# unregisterAsyncEventListener()
To unregister a callback for a specific event.
[AIHelpSupportSDK unregisterAsyncListenerWithEvent:YOUR_EVENT];
# Definition
# eventType
- Type:
EventType
- Details: Required All Events may be triggered. It's worthing noting that different events may carry different parameters, some may need a acknowledge callback.
# asyncEventListener
- Type:
(const char *jsonEventData, void (*acknowledge)(const char *jsonAckData))
- Details: Required The callback for registering an event.
- Explanation:
jsonEventData
: Event data in JSON formatacknowledge
: Use this callback method to send acknowledgment for several eventsjsonAckData
: Acknowledge data in JSON format
# Enumeration
# Initialization
- Enum: AIHelpEventInitialization
- Data:
{ "isSuccess": true, "message": "Success" }
- ACK:
-
# Logging In
- Enum: AIHelpEventUserLogin
- Data:
{ "code": 1, "message": "Success" }
- ACK:
-
# Authentication
- Enum: AIHelpEventEnterpriseAuth
- Data:
-
- ACK:
{ "token": "this_is_your_authenticated_token" }
# Unread Message
- Enum: AIHelpEventMessageArrival
- Data:
{ "msgCount": 1 }
- ACK:
-
# Unread Task
- Enum: AIHelpEventUnreadTaskCount
- Data:
{ "taskCount": 1 }
- ACK:
-
# Uploading Logs
- Enum: AIHelpEventLogUpload
- Data:
-
- ACK:
{ "content": "this_is_your_authenticated_token" }
# Clicking URLs
- Enum:
AIHelpEventUrlClick
- Data:
{ "url": "https://your.target.url?js-bridge=enable" }
- ACK:
-
- Details: When links containing
js-bridge=enable
as parameters are clicked, this event is triggered.
# Conversation Start
- 枚举值:
AIHelpEventConversationStart
- 数据:
{ "message": "this is the first message user sent" }
- ACK:
-
# Opening AIHelp
- Enum:
AIHelpEventSessionOpen
- Data:
-
- ACK:
-
# Closing AIHelp
- Enum:
AIHelpEventSessionClose
- Data:
-
- ACK:
-