@activatortube/supernova-sdk
TypeScript icon, indicating that this package has built-in type declarations

2.1.7 • Public • Published

SuperNova SDK项目

基于socket.io实现

Usage

安装

Web

npm install @activatortube/supernova-sdk
# 或者
yarn add @activatortube/supernova-sdk

React Native

  1. 添加依赖
# 1. 添加依赖
npm install @activatortube/supernova-sdk
# 或者
yarn add @activatortube/supernova-sdk
# 2. 添加react-native-get-random-values,比Web需要多一步
yarn add react-native-get-random-values
  1. 安装依赖
npx pod-install
  1. 然后在项目的起始位置引用
import 'react-native-get-random-values';

例子

import 'react-native-get-random-values';
import SuperNova from '@activatortube/supernova-sdk';

const Chat = () => {
  useEffect(() => {
    // 初始化项目
    SuperNova.init(Config.SUPERNOVA_ENDPOINT, 'debug');
    // 登录到聊天服务器
    const instance = SuperNova.getInstance();
    instance.login('', '');
    
    // 添加消息事件
    const messageHandler = (message: Message) => {
      console.log(`收到一条新消息:`, message);
      // TODO
    };
    SuperNova.getInstance().addMessageHandler(messageHandler);
    
    return () => {
      SuperNova.getInstance().removeMessageHandler(messageHandler);
    };
  }, []);
  // TODO
};

文档

API Reference

CHANGELOG

2.1.6 (2024-10-14)

Features

  • 添加删除对话功能 (07c236c) (李伟) (2024-10-14 14:21)

2.1.5 (2024-10-12)

Features

  • 好有信息添加备注字段 (ebbc6fa) (李伟) (2024-10-11 17:43)
  • 聊天会话添加好友详情信息 (ff805db) (李伟) (2024-10-11 17:19)
  • 消息添加创建时间字段 (f41cf35) (李伟) (2024-10-11 16:32)
  • 新增消息发送失败状态 (3e2097e) (李伟) (2024-10-10 14:05)
  • 添加上报推送token功能 (5e13767) (李伟) (2024-09-09 16:12)
  • 添加文件图片发送功能 (2857754) (李伟) (2024-09-05 11:18)
      1. 添加图片文件发送
      1. 可以发送自定义的消息类型

Bug Fixes

  • 修复message对象没有服务端ID错误 (d99001b) (李伟) (2024-08-20 16:03)

Readme

Keywords

Package Sidebar

Install

npm i @activatortube/supernova-sdk

Weekly Downloads

21

Version

2.1.7

License

ISC

Unpacked Size

72.8 kB

Total Files

26

Last publish

Collaborators

  • wheelerlee