更新记录

1.0.0(2024-09-13)

  1. 游客模式
  2. 用户登录模式
  3. 更新用户信息
  4. 记录用户事件
  5. 打开消息中心
  6. 支持多语言

平台兼容性

HbuilderX/cli最低兼容版本
3.6.8

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios app-harmony
? ? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

intercom几行代码接入客服聊天功能支持登录多语言记录事件等

主要功能

  1. 游客模式
  2. 用户登录模式
  3. 更新用户信息
  4. 记录用户事件
  5. 打开消息中心
  6. 支持多语言

集成步骤

  1. 拷贝demo里的AndroidManifest.xml、Info.plist到项目根目录
  2. 从intercom平台获取appKey、appId,https://app.intercom.com/a/apps/sj95wl05/settings/channels/messenger/install?tab=ios
  3. 集成插件步骤请参考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 {

    }
})
  • 用户登陆
  1. 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 {

    }
})
  1. 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 {

    }
})
  1. 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()
  • 设置用户hash

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)
  • 展示intercom空间

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 = ""
  • setBottomPadding

UTSIntercom.setBottomPadding(20)
  • displayMessageComposer

UTSIntercom.displayMessageComposer(“xxx”)
  • getUnreadConversationCount

let count = UTSIntercom.getUnreadConversationCount()
  • addUnreadConversationCountListener,仅支持Android

UTSIntercom.addUnreadConversationCountListener((resp)=>{

})
  • setInAppMessageVisibility

UTSIntercom.setInAppMessageVisibility(true)
  • hideIntercom

UTSIntercom.hideIntercom()
  • displayHelpCenter

UTSIntercom.displayHelpCenter()
  • displayArticle

let articleId = "xxx"
UTSIntercom.displayArticle(articleId)
  • displayHelpCenterCollections

let params = {}
params.collectionIds = [""]
UTSIntercom.displayHelpCenterCollections(params)

隐私、权限声明

1. 本插件需要申请的系统权限列表:

相机、麦克风

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件使用的 XX SDK会采集数据,详情可参考:https://developers.intercom.com

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问