更新记录
1.0.0(2024-09-13)
- 游客模式
- 用户登录模式
- 更新用户信息
- 记录用户事件
- 打开消息中心
- 支持多语言
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:5.0,iOS:13,HarmonyNext:不确定 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
intercom几行代码接入客服聊天功能支持登录多语言记录事件等
主要功能
- 游客模式
- 用户登录模式
- 更新用户信息
- 记录用户事件
- 打开消息中心
- 支持多语言
集成步骤
- 拷贝demo里的AndroidManifest.xml、Info.plist到项目根目录
- 从intercom平台获取appKey、appId,https://app.intercom.com/a/apps/sj95wl05/settings/channels/messenger/install?tab=ios
- 集成插件步骤请参考https://www.cnblogs.com/wenrisheng/p/18323027
如果需要配置聊天欢迎页的内容和样式,可以前往intercom平台上配置https://app.intercom.com/a/apps/sj95wl05/settings/channels/messenger/mobile-sdk?section=greeting&tab=content
接口文档
import {UTSIntercom} from "@/uni_modules/wrs-uts-intercom"
- 初始化,一般放到app启动到时候调用(App.vue的onLaunch方法里)
let params = {}
if(isAndroid) {
params.apiKey = "android_sdk-f523a162a956142d47a372ecd82c3da5259475aa"
params.appId = "sj95wl05"
} else {
params.apiKey = "ios_sdk-1d629b48871082900ebb594810507c0e994b0add"
params.appId = "sj95wl05"
}
UTSIntercom.setApiKey(params)
UTSIntercom.loginUnidentifiedUser((resp)=>{
let flag = resp.flag
if(flag) { // 登陆成功
} else {
}
})
- userId登陆
let loginParams = {}
loginParams.type = "userId" // 支持userId、email、userAttributes
loginParams.userId = "123456"
UTSIntercom.loginIdentifiedUser(loginParams,(resp)=>{
console.log(JSON.stringify(resp))
let flag = resp.flag
if(flag) { // 登陆成功
} else {
}
})
- email登陆
let loginParams = {}
loginParams.type = "email" // 支持userId、email、userAttributes
loginParams.email = "xxx@xxx"
UTSIntercom.loginIdentifiedUser(loginParams,(resp)=>{
console.log(JSON.stringify(resp))
let flag = resp.flag
if(flag) { // 登陆成功
} else {
}
})
-
userAttributes登陆
支持的语言有 Arabic, Bosnian, Brazilian Portuguese, Bulgarian, Catalan, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, German (Formal), Greek, Hebrew, Hungarian, Indonesian, Italian, Japanese, Korean, Latviski, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, Serbian, Simplified Chinese, Slovenian, Spanish, Swedish, Traditional Chinese, Turkish, Ukrainian, Vietnamese, and Англи хэл (Mongolian)
只有当language_override的值符合ISO 639-1的双字母代码,例如英语的'en'或法语的'fr'时,才会使用。你需要使用四个字母的中文代码,比如“zh-CN”。
let loginParams = {}
loginParams.type = "userAttributes" // 支持userId、email、userAttributes
loginParams.userAttributes = {
name: "xxx",
phone: "xxx",
email: "xxx",
languageOverride: "",
customAttribute: {
age: 16
}
}
UTSIntercom.loginIdentifiedUser(loginParams,(resp)=>{
console.log(JSON.stringify(resp))
let flag = resp.flag
if(flag) { // 登陆成功
} else {
}
})
UTSIntercom.logout()
UTSIntercom.setUserHash("xxxx")
let user = {
name: "xxx",
phone: "xxx",
email: "xxx",
languageOverride: "",
customAttribute: {
age: 16
}
}
UTSIntercom.updateUser(user, (resp)=>{
})
let name = "loginEvent"
let eventData = {
account: "xx"
}
UTSIntercom.logEvent(name, eventData)
let space = "" // 支持null、Home、Messages、HelpCenter、Tickets(Tickets只支持android)
UTSIntercom.present(space)
// 参数参考下面
let params = {}
params.type = "Article" // Article、Survey、Carousel、HelpCenterCollections、Conversation(Conversation只支持android)
params.id = ""
UTSIntercom.presentContent(params)
// Article
let params = {}
params.type = "Article"
params.id = ""
let params = {}
params.type = "Survey"
params.id = ""
let params = {}
params.type = "Carousel"
params.id = ""
let params = {}
params.type = "HelpCenterCollections"
params.ids = [""]
let params = {}
params.type = "Conversation"
params.id = ""
UTSIntercom.setBottomPadding(20)
UTSIntercom.displayMessageComposer(“xxx”)
- getUnreadConversationCount
let count = UTSIntercom.getUnreadConversationCount()
- addUnreadConversationCountListener,仅支持Android
UTSIntercom.addUnreadConversationCountListener((resp)=>{
})
- setInAppMessageVisibility
UTSIntercom.setInAppMessageVisibility(true)
UTSIntercom.hideIntercom()
UTSIntercom.displayHelpCenter()
let articleId = "xxx"
UTSIntercom.displayArticle(articleId)
- displayHelpCenterCollections
let params = {}
params.collectionIds = [""]
UTSIntercom.displayHelpCenterCollections(params)