im
-
QNIM
-
im
QNIM.init(config) ⇒ im
初始化SDK
Kind: static method of QNIM
Returns: im - im 对象
| Param | Type | Description |
|---|---|---|
| config | object |
SDK初始化设置 |
| config.appid | string |
APPID |
| config.ws | boolean |
连接地址前缀是否为ws/wss: true - 连接地址前缀为ws或wss, false - 连接地址前缀为http/https |
| config.autoLogin | boolean |
是否自动登录 |
Example
import QNIM from 'qnweb-im';
const config = {
appid: "YOUR_APP_ID",
ws: false,
autoLogin: true
};
const im = QNIM.init(config);
im.login(opt)
登录
Kind: method of im
| Param | Type | Description |
|---|---|---|
| opt | object |
|
| opt.name | string |
用户名 |
| opt.password | string |
密码 |
im.qrlogin(opt)
二维码登录
Kind: method of im
| Param | Type | Description |
|---|---|---|
| opt | object |
|
| opt.user_id | number |
用户ID |
| opt.password | string |
密码 |
im.tokenLogin(opt)
token登录
Kind: method of im
| Param | Type | Description |
|---|---|---|
| opt | object |
|
| opt.user_id | number |
用户ID |
| opt.token | string |
Token |
im.idLogin(opt)
使用用户ID和密码登录
Kind: method of im
| Param | Type | Description |
|---|---|---|
| opt | object |
|
| opt.user_id | number |
用户ID |
| opt.password | string |
密码 |
im.isLogin() ⇒ boolean
是否已登录
Kind: method of im
Returns: boolean - 是否已登录
im.on(options, ext)
事件监听
Kind: method of im
| Param | Type | Description |
|---|---|---|
| options | Event |
Object.<Event, EventCallback> |
| ext | EventCallback |
undefined |
Example
im.on('event', (ret) => {
//do something with ret
})
// or
im.on({
eventName: (ret) => {
//do something with ret
},
...
})
im.off(options, ext)
取消监听
Kind: method of im
| Param | Type | Description |
|---|---|---|
| options | Event |
Object.<Event, EventCallback> |
| ext | EventCallback |
undefined |
Example
im.off('events', (ret) => {
//do something with ret
})
// or
im.off({
eventName: (ret) => {
//do something with ret
},
...
})
im.logout()
退出账户
Kind: method of im
文档反馈
(如有产品使用问题,请 提交工单)