[英]How can I check if "Do not Disturb mode" is enabled using Swift 4
I am building a live streaming mobile App that requires "Do not Disturb mode" to be enabled before starting any streaming session.我正在构建一个直播移动应用程序,它需要在开始任何流媒体会话之前启用“请勿打扰模式”。 How can I check that using Swift 4?
如何使用 Swift 4 进行检查?
There have been answers about this in Obj-C, so I've done my due diligence and converted it to Swift 5. Hope this helps:在 Obj-C 中有关于这个的答案,所以我已经完成了我的尽职调查并将其转换为 Swift 5。希望这会有所帮助:
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: handle)
(provider as? CXProvider)?.reportNewIncomingCall(with: uuid, update: update) { error in
if error != nil {
print("error when reporting imconing: \(error?.localizedDescription ?? "")")
(com.apple.CallKit.error.incomingcall error 3.)
if (error as NSError?)?.code == CXErrorCodeIncomingCallError.Code.filteredByDoNotDisturb.rawValue {
print("Disturb mode is on!")
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.