更新记录
1.0.3-beta(2025-07-14)
更新示例项目
1.0.2-beta(2025-07-14)
更新示例项目
1.0.1-beta(2025-07-14)
更新示例项目
查看更多平台兼容性
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | × | 13 | × | × |
UTS环境兼容性
uni-app | uni-app x |
---|---|
√ | √ |
crcPlus-linphone
Linphone SDK 集成插件,支持 iOS 平台的 VoIP 通话功能。
功能特性
- ✅ Linphone SDK 集成和检测
- ✅ SDK 状态验证
- ✅ 连接测试
- ✅ 版本信息获取
- ✅ 同步和异步方法支持
安装配置
iOS 配置
插件已预配置 Linphone SDK 依赖:
{
"deploymentTarget": "12.0",
"enableLocalPods": true,
"dependencies-pod-sources": [
"https://gitlab.linphone.org/BC/public/podspec.git"
],
"dependencies-pods": [
{
"name": "linphone-sdk",
"version": "~>5.3.0"
}
]
}
API 文档
1. 检测 SDK 引入状态
import { checkLinphoneSDK, checkLinphoneSDKAsync } from "@/uni_modules/crcPlus-linphone"
// 同步方法
const result = checkLinphoneSDK()
console.log(result)
// 返回格式:
// {
// code: 0, // 0=成功, -1=失败
// data: {
// success: true,
// message: "Linphone SDK 引入成功",
// version: "5.3.x",
// sdkLoaded: true
// }
// }
// 异步方法
checkLinphoneSDKAsync((result) => {
console.log('SDK检测结果:', result)
})
2. 获取 SDK 详细信息
import { getLinphoneInfo, getLinphoneInfoAsync } from "@/uni_modules/crcPlus-linphone"
// 同步方法
const info = getLinphoneInfo()
console.log(info)
// 返回格式:
// {
// code: 0,
// data: {
// success: true,
// version: "5.3.x",
// userAgent: "LinphoneSDK/5.3.x",
// buildInfo: {
// version: "5.3.x"
// }
// }
// }
// 异步方法
getLinphoneInfoAsync((result) => {
console.log('SDK信息:', result)
})
3. 测试连接
import { testLinphoneConnection, testLinphoneConnectionAsync } from "@/uni_modules/crcPlus-linphone"
// 同步方法
const testResult = testLinphoneConnection()
console.log(testResult)
// 返回格式:
// {
// code: 0,
// data: {
// success: true,
// networkReachable: true,
// coreCreated: true,
// message: "Linphone 核心组件创建成功"
// }
// }
// 异步方法
testLinphoneConnectionAsync((result) => {
console.log('连接测试结果:', result)
})
4. 原始测试方法
import { myTest, myTestSync } from "@/uni_modules/crcPlus-linphone"
// 异步测试
myTest((result) => {
console.log('测试结果:', result)
})
// 同步测试
const result = myTestSync()
console.log('同步测试结果:', result)
使用示例
参考 pages/index/index.vue
文件中的完整示例:
<template>
<view class="content">
<button @tap="checkSDK">检测 SDK 状态</button>
<button @tap="getSDKInfo">获取 SDK 信息</button>
<button @tap="testConnection">测试连接</button>
<view v-if="testResult">
<text>{{testResult}}</text>
</view>
</view>
</template>
<script>
import { checkLinphoneSDK, getLinphoneInfo, testLinphoneConnection } from "@/uni_modules/crcPlus-linphone"
export default {
data() {
return {
testResult: ''
}
},
methods: {
checkSDK() {
const result = checkLinphoneSDK()
this.testResult = JSON.stringify(result, null, 2)
},
getSDKInfo() {
const result = getLinphoneInfo()
this.testResult = JSON.stringify(result, null, 2)
},
testConnection() {
const result = testLinphoneConnection()
this.testResult = JSON.stringify(result, null, 2)
}
}
}
</script>
错误处理
所有方法都包含错误处理,返回统一的结果格式:
// 成功时
{
code: 0,
data: { /* 具体数据 */ }
}
// 失败时
{
code: -1,
data: {
success: false,
error: "错误信息",
message: "用户友好的错误描述"
}
}
注意事项
- 该插件仅支持 iOS 平台
- 需要 iOS 12.0 及以上版本
- 首次使用时会自动下载 Linphone SDK 依赖
- 建议在真机上测试完整功能
版本历史
- v1.0.0: 基础功能实现
- v1.1.0: 添加 Linphone SDK 集成和检测功能