XuqmGroup-Web/docs-site/docs/android/index.md
XuqmGroup dadedbc4df feat: add VitePress docs-site with full SDK integration guides
- Add docs-site workspace (VitePress 1.5.0) with Android/iOS/RN/Vue3/HarmonyOS/Server docs
- Update Dockerfile to build and serve docs under /docs/
- Add /docs/ location block to Nginx config
- Add docs-site to yarn workspaces

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 15:35:24 +08:00

1.9 KiB

Android SDK 概览

版本0.1.0 · 最低 Android 版本API 24 (Android 7.0) · 语言Kotlin

功能模块

模块 Artifact 功能
sdk-core com.xuqm:sdk-core 初始化、网络、鉴权、设备信息
sdk-im com.xuqm:sdk-im 单聊、群聊、消息收发
sdk-push com.xuqm:sdk-push 设备 Token 注册、离线推送
sdk-update com.xuqm:sdk-update App 更新检查、RN 热更新

快速接入

1. 添加依赖

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven("https://nexus.xuqinmin.com/repository/android/")
        google(); mavenCentral()
    }
}
// app/build.gradle.kts
dependencies {
    implementation("com.xuqm:sdk-core:0.1.0")
    implementation("com.xuqm:sdk-im:0.1.0")     // 按需
    implementation("com.xuqm:sdk-update:0.1.0") // 按需
}

2. 初始化

// Application.onCreate()
XuqmSDK.init(
    context = this,
    appKey = "your_app_id",
    appSecret = "your_app_secret",      // 建议由服务端签发临时凭证
    apiBaseUrl = "https://sentry.xuqinmin.com",
    imBaseUrl = "wss://sentry.xuqinmin.com/ws/im",
    debug = BuildConfig.DEBUG
)

3. IM 登录与收消息

// 先从你的服务端换取 IM Token,再登录
ImSDK.login(
    appId = "your_app_id",
    userId = "user_001",
    nickname = "张三"
)

// 监听事件
ImSDK.addListener(object : ImEventListener {
    override fun onConnected() { /* WebSocket 已连接 */ }
    override fun onMessage(msg: ImMessage) { /* 处理收到的消息 */ }
    override fun onDisconnected(reason: String?) { /* 断线处理 */ }
})

4. 发送消息

ImSDK.sendMessage(
    toId = "user_002",
    chatType = ChatType.SINGLE,
    msgType = MsgType.TEXT,
    content = "Hello!"
)

→ 完整安装配置 · → IM 接入详解 · → API Reference