im-chat-sdk
v1.0.2
Published
``` 默认安装最新版``` ``` npm i im-chat-sdk```
Downloads
16
Readme
im-chat-sdk
安装
默认安装最新版
npm i im-chat-sdk
使用说明
1.导入 import {initIchat,useIchat} from 'im-chat-sdk'
(1)、initIchat 为初始化方法,传入 对应url eg:https://www.xxxx.com?agentId=123123&uuid=qqww
2.使用hooks
eg: const ichat = useIchat()
3.方法调用
eg:ichat.getMessageCount()
说明:
1.Function initIchat //(初始化)
function initIchat(): Promise<void>
2.Function getMessageCount //(获取消息条数)
function getMessageCount(): Promise<any>
--> getMessageCount 调用频率为最大 10次/min 请注意使用
demo
vue组件使用
<template>
<button @click="clickButton"> test button</button>
</template>
<script setup>
import {initIchat, useIchat} from 'im-chat-sdk'
import {onMounted} from "vue";
const ichat = useIchat()
onMounted(async ()=>{
await initIchat('https://www.xxxx.com?agentId=123123&uuid=qqww')
})
const clickButton = async () => {
let {data} = await ichat.getMessageCount()
console.log('用户当前未读消息数量为:',data)
}
</script>
js 环境
import {initIchat, useIchat} from 'im-chat-sdk'
//example start
async function init(){
await initIchat('https://www.xxxx.com?agentId=123123&uuid=qqww')
}
function startListinig(){
let timer = window.setInterval(async ()=>{
let {data} = await ichat.getMessageCount()
console.log('用户当前未读消息数量为:',data)
},1*60*1000/10)
}