# 工具方法
为了方便接入和调试,我们提供了一些工具类 API,你可以根据情况自行选择。
# close()
关闭所有 AIHelp 页面
AIHelpSupport.close();
# enableLogging()
是否打开日志
AIHelpSupport.enableLogging(true);
# getSDKVersion()
获取当前 AIHelp 版本信息
String sdkVersion = AIHelpSupport.getSDKVersion();
# isAIHelpShowing()
当前展示的是否为 AIHelp 页面
boolean isShowing = AIHelpSupport.isAIHelpShowing();
# setOnSpecificUrlClickedCallback()
利用此 API 来接管某个超链接的点击事件,具体配置方法如下:
1、为超链接配置 js-bridge=enable
参数,如:https://www.google.com?js-bridge=enable
2、设置回调来接管配置了 js-bridge=enable 的超链接的点击事件:
AIHelpSupport.setOnSpecificUrlClickedCallback((url) -> {
// url: https://www.google.com?js-bridge=enable
// You can get the callback when user clicked the specific url
});
# setOnAIHelpSessionOpenCallback()
注册 AIHelp 页面打开的回调通知:
AIHelpSupport.setOnAIHelpSessionOpenCallback(() -> {
// You can get the callback when user opened the AIHelp page
});
# setOnAIHelpSessionCloseCallback()
注册 AIHelp 页面关闭的回调通知:
AIHelpSupport.setOnAIHelpSessionCloseCallback(() -> {
// You can get the callback when user closed the AIHelp page
});
# setOnOperationUnreadChangedCallback()
注册运营文章更新时的回调通知:
AIHelpSupport.setOnOperationUnreadChangedCallback((hasUnreadArticles) -> {
// do something you want according to the unread status received
});
# additionalSupportFor()
为以下国家或地区提供额外的域名支持:
- 印度地区
- 中国大陆地区
需要注意的是,此方法必须在 init 开始之前调用,如下所示:
if (USER_FROM_MAINLAND_CHINA) {
AIHelpSupport.additionalSupportFor(PublishCountryOrRegion.CN);
}
AIHelpSupport.init(this, "appKey", "domain", "appId", "defaultLanguage(optional)");