更新记录
1.0.0(2026-03-22)
平台兼容性
uni-app(4.87)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-vue插件版本 |
app-nvue |
app-nvue插件版本 |
Android |
Android插件版本 |
iOS |
鸿蒙 |
| - |
- |
- |
- |
√ |
1.0.0 |
√ |
1.0.0 |
8.0 |
1.0.0 |
- |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
概述
- 支持获取通话录音文件
- 支持获取通话记录
- 支持实时监听电话状态
- 支持实时监听短信状态
- 支持拨打电话、静默发送短信、获取短信
- 支持添加、获取手机通讯录
- 支持检查、开启前台通知服务
温馨提示 如何调用插件
import {
checkCallAutoRecorder,
toCallAutoRecorderPage,
getAllRecorderFiles,
getRecorderFiles,
getAllCalls,
getCalls,
registerListener,
isRegisterListener,
unRegisterListener,
getSettingsKeyValue,
callPhone,
registerSmsListener,
unRegisterSmsListener,
isMultiSim,
hideSendSms,
getSms,
getPhoneNumber,
getCallState,
checkAllFilesPermission,
toAllFilesPermissionPage,
getContacts,
addContact,
isForegroundPermission,
toForegroundPage,
startForeground,
stopForeground
} from "@/uni_modules/yuange-phonestate"
检测是否开启通话自动录音
checkCallAutoRecorder({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
跳转到开启通话自动录音页面
toCallAutoRecorderPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取所有录音文件
getAllRecorderFiles({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
根据条件搜索录音文件
getRecorderFiles(1711209600000, new Date().getTime(), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取所有通话记录
getAllCalls({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
根据条件获取通话记录
let json = {
//条件,1.根据号码查找,2.根据名称查找,3.根据时间段查找,4.联合查询
type: 1,
//查找的内容,type=1和2时有效
value: '***',
//根据时间段查找,type=3时有效
times: [0, 1772092002776],
//联合查询参数,type=4时有效
params: {
//查询的姓名
name: "张三",
//查询的手机号码
number: "",
//查询的时间段
times: [1711814400000, 1711900799000],
}
};
getCalls(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取设置的key和value
getSettingsKeyValue({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
注册电话监听
registerListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
取消电话监听
unRegisterListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
判断电话监听状态
isRegisterListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
是否是双卡
isMultiSim({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
拨打电话
let json = {
// 拨打号码
number: "10010",
// 卡槽索引,1.卡槽1(默认),2.卡槽2
slot: 1
};
callPhone(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
注册短信监听
registerSmsListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
取消短信监听
unRegisterSmsListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
静默发送短信
let json = {
//发送短信的号码
phoneNumber: "10010",
//发送内容
message: "剩余话费",
};
hideSendSms(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取短信列表
let json = {
//短信内容,模糊搜索
content: "流量",
//发件人号码
phoneNumber: "10010"
};
getSms(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取电话号码
getPhoneNumber({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取当前通话状态
getCallState({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
检查是否有“所有文件”访问权限
checkAllFilesPermission({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
跳转到所有文件访问权限页面
toAllFilesPermissionPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
获取手机通讯录
let json = {
//手机号码,可以为空
phoneNumber: "",
//姓名
name: "测试"
};
getContacts(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
添加通讯录
let json = {
//手机号码
phoneNumber: "***",
//姓名
name: "测试"
};
addContact(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
开启前台通知服务
let json = {
//前台通知服务标题
title: "电话通话监听原生插件",
//前台通知服务内容
content: "电话通话监听原生插件正在运行中",
//icon图标名称,不需要加后缀名,需放置到【nativeResources】>【android】> 【res】> 【mipmap-xxhdpi】>图片文件
icon: "test"
};
startForeground(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
关闭前台通知服务
stopForeground({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
是否有前台通知权限
isForegroundPermission({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
跳转到通知权限页面
toForegroundPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
完整Demo示例
<template>
<view>
<button type="primary" @click="checkCallAutoRecorder_">检测是否开启通话自动录音</button>
<button type="primary" @click="toCallAutoRecorderPage_">跳转到开启通话自动录音页面</button>
<button type="primary" @click="getAllRecorderFiles_">获取所有的录音文件</button>
<button type="primary" @click="getRecorderFiles_">根据条件搜索录音文件</button>
<button type="primary" @click="getAllCalls_">获取所有的通话记录</button>
<button type="primary" @click="getCalls_">根据条件获取通话记录</button>
<button type="primary" @click="getSettingsKeyValue_">获取设置的key和value</button>
<button type="primary" @click="registerListener_">注册电话监听</button>
<button type="primary" @click="unRegisterListener_">取消电话监听</button>
<button type="primary" @click="isRegisterListener_">电话监听状态</button>
<button type="primary" @click="isMultiSim_">是否是双卡</button>
<button type="primary" @click="callPhone_">拨打电话</button>
<button type="primary" @click="registerSmsListener_">注册短信监听</button>
<button type="primary" @click="unRegisterSmsListener_">取消短信监听</button>
<button type="primary" @click="hideSendSms_">静默发送短信</button>
<button type="primary" @click="getSms_">获取短信列表</button>
<button type="primary" @click="getPhoneNumber_">获取手机号码</button>
<button type="primary" @click="getCallState_">获取当前通话状态</button>
<button type="primary" @click="checkAllFilesPermission_">检查是否有“所有文件”访问权限</button>
<button type="primary" @click="toAllFilesPermissionPage_">跳转到所有文件访问权限页面</button>
<button type="primary" @click="getContacts_">获取手机通讯录</button>
<button type="primary" @click="addContact_">添加通讯录</button>
<button type="primary" @click="isForegroundPermission_">是否有前台通知权限</button>
<button type="primary" @click="toForegroundPage_">跳转到通知权限页面</button>
<button type="primary" @click="startForeground_">开启前台通知服务</button>
<button type="primary" @click="stopForeground_">关闭前台通知服务</button>
</view>
</template>
<script>
import {
checkCallAutoRecorder,
toCallAutoRecorderPage,
getAllRecorderFiles,
getRecorderFiles,
getAllCalls,
getCalls,
registerListener,
isRegisterListener,
unRegisterListener,
getSettingsKeyValue,
callPhone,
registerSmsListener,
unRegisterSmsListener,
isMultiSim,
hideSendSms,
getSms,
getPhoneNumber,
getCallState,
checkAllFilesPermission,
toAllFilesPermissionPage,
getContacts,
addContact,
isForegroundPermission,
toForegroundPage,
startForeground,
stopForeground
} from "@/uni_modules/yuange-phonestate"
export default {
data() {
return {}
},
methods: {
// 检测是否开启通话自动录音
checkCallAutoRecorder_() {
checkCallAutoRecorder({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 跳转到开启通话自动录音页面
toCallAutoRecorderPage_() {
toCallAutoRecorderPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取所有录音文件
getAllRecorderFiles_() {
getAllRecorderFiles({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//根据条件搜索录音文件
getRecorderFiles_() {
getRecorderFiles(1711209600000, new Date().getTime(), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取所有通话记录
getAllCalls_() {
getAllCalls({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 根据条件获取通话记录
getCalls_() {
let json = {
//条件,1.根据号码查找,2.根据名称查找,3.根据时间段查找,4.联合查询
type: 1,
//查找的内容,type=1和2时有效
value: '***',
//根据时间段查找,type=3时有效
times: [0, 1772092002776],
//联合查询参数,type=4时有效
params: {
//查询的姓名
name: "张三",
//查询的手机号码
number: "",
//查询的时间段
times: [1711814400000, 1711900799000],
}
};
getCalls(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取设置的key和value
getSettingsKeyValue_() {
getSettingsKeyValue({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//注册电话监听
registerListener_() {
registerListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//取消电话监听
unRegisterListener_() {
unRegisterListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//判断电话监听状态
isRegisterListener_() {
isRegisterListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//是否是双卡
isMultiSim_() {
isMultiSim({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
//拨打电话
callPhone_() {
let json = {
// 拨打号码
number: "10010",
// 卡槽索引,1.卡槽1(默认),2.卡槽2
slot: 1
};
callPhone(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 注册短信监听
registerSmsListener_() {
registerSmsListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 取消短信监听
unRegisterSmsListener_() {
unRegisterSmsListener({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 静默发送短信
hideSendSms_() {
let json = {
//发送短信的号码
phoneNumber: "10010",
//发送内容
message: "剩余话费",
};
hideSendSms(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取短信列表
getSms_() {
let json = {
//短信内容,模糊搜索
content: "流量",
//发件人号码
phoneNumber: "10010"
};
getSms(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取电话号码
getPhoneNumber_() {
getPhoneNumber({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取当前通话状态
getCallState_() {
getCallState({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 检查是否有“所有文件”访问权限
checkAllFilesPermission_() {
checkAllFilesPermission({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 跳转到所有文件访问权限页面
toAllFilesPermissionPage_() {
toAllFilesPermissionPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 获取手机通讯录
getContacts_() {
let json = {
//手机号码,可以为空
phoneNumber: "",
//姓名
name: "测试"
};
getContacts(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 添加通讯录
addContact_() {
let json = {
//手机号码
phoneNumber: "***",
//姓名
name: "测试"
};
addContact(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 开启前台通知服务
startForeground_() {
let json = {
//前台通知服务标题
title: "电话通话监听原生插件",
//前台通知服务内容
content: "电话通话监听原生插件正在运行中",
//icon图标名称,不需要加后缀名,需放置到【nativeResources】>【android】> 【res】> 【mipmap-xxhdpi】>图片文件
icon: "test"
};
startForeground(JSON.stringify(json), {
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 关闭前台通知服务
stopForeground_() {
stopForeground({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 是否有前台通知权限
isForegroundPermission_() {
isForegroundPermission({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
// 跳转到通知权限页面
toForegroundPage_() {
toForegroundPage({
onCallback(res) {
console.log(JSON.stringify(res));
}
});
},
}
}
</script>
<style>
</style>