更新记录
1.0.0(2026-02-12)
首发
平台兼容性
uni-app(4.85)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.81)
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|
| - | - | - | - | - | - |
Phone Call Plugin - 电话通话录音插件 (UTS版本)
插件简介
Phone Call Plugin 是一个基于 UTS 开发的 Android 原生插件,提供电话通话、录音等功能。支持直接拨号、通话监听等核心功能。
功能特性
📞 拨号功能
- ✅ 直接拨打电话(ACTION_CALL,无需用户确认)
- ✅ 跳转拨号界面(ACTION_DIAL)
- ✅ 双卡槽支持
📱 通话控制
- ✅ 接听电话
- ✅ 挂断电话
🔧 设备信息
- ✅ 获取设备信息
插件结构
phone-call-plugin/
├── package.json # 插件配置
├── index.js # JavaScript 封装层
├── readme.md # 使用文档
├── changelog.md # 更新日志
└── utssdk/ # UTS SDK 目录
└── app-android/ # Android 平台代码
├── index.uts # UTS 入口文件
└── config.json # Android 配置
安装使用
1. 导入插件
将 phone-call-plugin 目录放置到项目的 uni_modules 目录下。
2. 配置权限
在 manifest.json 中添加以下权限:
{
"app-plus": {
"distribute": {
"android": {
"permissions": [
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>"
]
}
}
}
}
3. 打包自定义基座
重要:UTS 插件必须在自定义基座中运行!
HBuilderX → 运行 → 运行到手机或模拟器 → 制作自定义调试基座
4. 使用自定义基座运行
HBuilderX → 运行 → 运行到手机或模拟器 → 运行到自定义调试基座
API 文档
基础方法
isAvailable()
检查插件是否可用
import { isAvailable } from '@/uni_modules/phone-call-plugin'
if (isAvailable()) {
console.log('插件可用')
}
checkPermissions()
检查权限状态
import { checkPermissions } from '@/uni_modules/phone-call-plugin'
const result = await checkPermissions()
console.log('权限状态:', result.permissions)
拨号功能
dialNumber(phoneNumber, options)
拨打电话
参数说明:
phoneNumber(String): 电话号码options(Object): 拨号选项directCall(Boolean): 是否直接拨号,默认 truetrue: 使用 ACTION_CALL,直接拨号无需用户确认false: 使用 ACTION_DIAL,跳转到拨号界面slotId(Number): SIM 卡槽 ID(1 或 2),默认 1
示例:
import { dialNumber } from '@/uni_modules/phone-call-plugin'
// 直接拨号(推荐)
const result = await dialNumber('***', {
directCall: true,
slotId: 1
})
if (result.code === 0) {
console.log('拨号成功')
} else {
console.error('拨号失败:', result.message)
}
// 跳转到拨号界面
await dialNumber('***', {
directCall: false
})
通话控制
endCall()
挂断电话(需要系统权限)
import { endCall } from '@/uni_modules/phone-call-plugin'
const result = await endCall()
answerCall()
接听电话(需要系统权限)
import { answerCall } from '@/uni_modules/phone-call-plugin'
const result = await answerCall()
设备信息
getDeviceInfo()
获取设备信息
import { getDeviceInfo } from '@/uni_modules/phone-call-plugin'
const deviceInfo = await getDeviceInfo()
console.log('设备信息:', deviceInfo)
完整示例
<template>
<view class="container">
<input v-model="phoneNumber" placeholder="请输入电话号码" />
<button @click="handleDirectCall">直接拨号</button>
<button @click="handleDialCall">跳转拨号</button>
<button @click="checkPermissions">检查权限</button>
<button @click="getDevice">获取设备信息</button>
</view>
</template>
<script>
import {
isAvailable,
checkPermissions,
dialNumber,
getDeviceInfo
} from '@/uni_modules/phone-call-plugin'
export default {
data() {
return {
phoneNumber: ''
}
},
onLoad() {
console.log('插件可用:', isAvailable())
},
methods: {
async handleDirectCall() {
if (!this.phoneNumber) {
uni.showToast({ title: '请输入电话号码', icon: 'none' })
return
}
try {
uni.showLoading({ title: '正在拨号...', mask: true })
const result = await dialNumber(this.phoneNumber, {
directCall: true,
slotId: 1
})
uni.hideLoading()
if (result.code === 0) {
uni.showToast({ title: '拨号成功', icon: 'success' })
} else {
uni.showToast({
title: '拨号失败: ' + result.message,
icon: 'none'
})
}
} catch (error) {
uni.hideLoading()
console.error('拨号失败:', error)
}
},
async handleDialCall() {
if (!this.phoneNumber) {
uni.showToast({ title: '请输入电话号码', icon: 'none' })
return
}
try {
const result = await dialNumber(this.phoneNumber, {
directCall: false
})
console.log('跳转拨号结果:', result)
} catch (error) {
console.error('拨号失败:', error)
}
},
async checkPermissions() {
const result = await checkPermissions()
console.log('权限状态:', result)
uni.showModal({
title: '权限状态',
content: JSON.stringify(result.permissions, null, 2),
showCancel: false
})
},
async getDevice() {
const result = await getDeviceInfo()
console.log('设备信息:', result)
uni.showModal({
title: '设备信息',
content: JSON.stringify(result.deviceInfo, null, 2),
showCancel: false
})
}
}
}
</script>
注意事项
⚠️ 必须使用自定义基座
UTS 插件必须在自定义基座中运行,标准基座无法使用!
制作自定义基座步骤:
- HBuilderX → 运行 → 运行到手机或模拟器 → 制作自定义调试基座
- 选择 Android 平台
- 等待打包完成(约 2-5 分钟)
运行自定义基座步骤:
- HBuilderX → 运行 → 运行到手机或模拟器 → 运行到自定义调试基座
- 等待应用启动
🔑 权限要求
- 直接拨号需要
CALL_PHONE权限 - 通话监听需要
READ_PHONE_STATE权限 - 首次使用时会自动请求权限
📱 系统要求
- Android 版本:Android 5.0+(API 21+)
- 双卡支持:部分设备可能需要特殊处理
常见问题
Q: 提示"插件不可用"?
A: 检查是否使用自定义基座运行,UTS 插件必须在自定义基座中使用。
Q: 直接拨号跳转到拨号界面?
A:
- 确认使用自定义基座运行
- 确认
directCall: true参数 - 确认已授予 CALL_PHONE 权限
Q: 如何查看插件是否加载?
A: 使用 isAvailable() 方法检查:
console.log('插件可用:', isAvailable())
Q: 权限被拒绝怎么办?
A:
- 在手机设置中手动授予权限
- 或重新安装应用并允许权限
更新日志
v1.0.0 (2025-02-12)
- 初始版本发布
- 支持直接拨号、跳转拨号
- 支持接听/挂断电话
- 支持获取设备信息
技术支持
如有问题,请提交 Issue 或联系开发者。
最后更新: 2025-02-12
插件版本: v1.0.0
开发语言: UTS (UniApp TypeScript)

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 2
赞赏 0
下载 11222225
赞赏 1860
赞赏
京公网安备:11010802035340号