🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@xkit-yx/call-kit-react-ui

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xkit-yx/call-kit-react-ui

呼叫UI组件

0.10.0
latest
npm
Version published
Weekly downloads
1
-87.5%
Maintainers
0
Weekly downloads
 
Created
Source

网易云信

安装

npm install @xkit-yx/call-kit-react-ui
// or
yarn add @xkit-yx/call-kit-react-ui

单呼

使用示例

初始化

import React, { useState, useEffect } from 'react'
import { CallViewProvider } from '@xkit-yx/call-kit-react-ui'
import NIM from 'xxxx' // im sdk path

// ...

export default () => {
  const [nim, setNim] = useState()

  useEffect(() => {
    const im = NIM.getInstance({
      appKey: 'xxxx', // im appkey
      token: 'xxxx', // im token
      account: 'xxxx', // im account
      debugLevel: 'debug',
      lbsUrls: ['xxxx'],
      linkUrl: 'xxxx',
      onconnect: () => {
        setNim(im)
      },
    })
    return () => {
      im.disconnect()
    }
  }, [])

  return nim ? (
    <CallViewProvider
      neCallConfig={{
        nim,
        appKey,
        currentUserInfo: { accId: 'xxx' }, // 当前用户的accId
        debug: true,
      }}
      position={{
        x: 500,
        y: 10,
      }}
    >
      <App />
    </CallViewProvider>
  ) : null
}

其他子组件

import { useCall } from '@xkit-yx/call-kit-react-ui'

// ...

export default () => {
  const { call } = useCall()
  const handleClick = () => {
    call({
      accId: 'userId',
      type: '2',
    })
  }
  return <button onClick={handleClick}>发起呼叫</button>
}

群呼

使用示例

初始化

import React, { useState, useEffect } from 'react'
import {
  GroupCallViewProvider,
  GroupCallViewProviderRef,
} from '@xkit-yx/call-kit-react-ui'
import NIM from 'xxxx' // im sdk path

// ...

export default () => {
  const [nim, setNim] = useState()
  const groupCallViewProviderRef = useRef<GroupCallViewProviderRef>(null)

  useEffect(() => {
    const im = NIM.getInstance({
      appKey: 'xxxx', // im appkey
      token: 'xxxx', // im token
      account: 'xxxx', // im account
      debugLevel: 'debug',
      lbsUrls: ['xxxx'],
      linkUrl: 'xxxx',
      onconnect: () => {
        setNim(im)
      },
      shouldIgnoreMsg: (msg) => {
        if (msg.type === 'custom') {
          return groupCallViewProviderRef.current?.onMsg?.(msg.content)
        } else {
          return false
        }
      },
    })
    return () => {
      im.disconnect()
    }
  }, [])

  return nim ? (
    <GroupCallViewProvider
      neGroupCallConfig={{
        nim,
        currentUserInfo: { accId: 'xxx' },
        appKey,
        debug: true,
      }}
      position={{ x: 500, y: 10 }}
      ref={groupCallViewProviderRef}
    >
      <App />
    </GroupCallViewProvider>
  ) : null
}

其他子组件

import { useGroupCall } from '@xkit-yx/call-kit-react-ui'

// ...

export default () => {
  const { groupCall } = useGroupCall()
  const handleClick = () => {
    groupCall({ calleeList: ['xxxxx'] })
  }
  return <button onClick={handleClick}>发起呼叫</button>
}

FAQs

Package last updated on 08 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts