swift - SWIFT:当拨出电话接通时振动
问题描述
当拨出电话接通时,我试图振动。但是,在委托功能中,我可以捕获此事件,但振动功能无法按预期工作。通话结束时手机震动.......
print("**************** call.hasConnected") 按预期工作。
func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
print("isOutgoing: \(call.isOutgoing ? "true, ":"false, ")" +
"hasConnected: \(call.hasConnected ? "true, ":"false, ")" +
"hasEnded: \(call.hasEnded ? "true, ":"false, ")" +
"isOnHold: \(call.isOnHold ? "true":"false")\n")
if call.isOutgoing && !call.hasConnected && !call.hasEnded {
print("**************** call.isOutgoing")
some codes here.
}
if call.isOutgoing && call.hasConnected && !call.hasEnded {
print("**************** call.hasConnected")
//AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
}
if (call.isOutgoing && call.hasConnected && call.hasEnded) {
print("**************** call.hasEnded")
}
}
解决方案
推荐阅读
- laravel - Laravel:搜索查询
- facebook-graph-api - Facebook Workplace Graph API - 如何使用群组名称获取群组 ID
- node.js - Jenkins 管道 - 如何从一个节点启动 node.js 应用程序并在不同节点中使用它?
- scala - 组合柯里化函数
- sql-server - 在 SSMS 中,登录名右侧显示的数字是多少?
- android - 错误:(246, 5) 错误:资源 'attr/font' 与配置 '' 的重复值
- vba - 行源行为在不重新加载用户表单的情况下不更新/重置列表框 // 使用 list = 范围获取列标题
- oracle - 未启用 Oracle 约束
- r - 矩阵中特定行的行和
- wpf - 样式中的 WPF 命令绑定 ItemsControl