更新记录
1.01(2025-03-17)
1.0.0(2025-03-17) 安卓电话通话监听,来电去电监听,支持获取所有录音文件 自动跳转到手机自带的录音界面查看搜索录音信息
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | 4.4 | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
uni-app x
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | 5.0 | - | - | - |
android 电话监听,录音文件获取 说明文档
模块
import {
startPhoneListener,
stopPhoneListener,
checkIsAutoRecord,
toCallAutoRecorderPage,
navigateToCallRecordingSettings,
jumpToPermissionPage,
makePhoneCall,
allRecorderFilesAction,
registerSmsReceiver,
} from '@/uni_modules/yao-lister';
对应的权限不能忘记
async initPhoneStateListener() {
// 动态申请权限
const permissions = ["android.permission.READ_PHONE_STATE",
"android.permission.ANSWER_PHONE_CALLS", "android.permission.CALL_PHONE",
"android.permission.MANAGE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.READ_CALL_LOG",
"android.permission.READ_PHONE_NUMBERS",
"android.permission.FOREGROUND_SERVICE",
"android.permission.RECEIVE_SMS",
"android.permission.READ_SMS"
]
const result = await plus.android.requestPermissions(permissions, 1001)
if (result.granted) {
startListening()
// 监听原生事件
uni.$on('PHONE_STATE_CHANGE', (state) => {
this.phoneState = state
})
}
}
开启,关闭电话监听
startListerPhone() {
startPhoneListener(res => {
uni.showToast({
icon: 'success',
title: '电话监听开启',
duration: 2000
});
this.phoneState = res + "012"
})
},
stopListerPhone() {
stopPhoneListener(res => {
uni.showToast({
icon: 'success',
title: res,
duration: 2000
});
})
},
其他的demo里面 可以直接查看,有问题,直接微信找我 demo1223
allRecorderFilesAction() {
const _this = this;
allRecorderFilesAction(res => {
console.log("录音文件输入", JSON.stringify(res))
_this.toggle('bottom');
_this.Filelist = res
uni.showToast({
title: JSON.stringify(res),
duration: 2000
})
})
},
jumpToPermissionPage() {
jumpToPermissionPage()
},
navigateToCallRecordingSettings() {
navigateToCallRecordingSettings()
},
toCallAutoRecorderPage() {
toCallAutoRecorderPage()
},
checkIsAutoRecord() {
let checkRecord = checkIsAutoRecord()
uni.showToast({
title: checkRecord ? "已开启电话录音" : "未开启电话录音",
duration: 2000
})
},