如何使用 Swift 4 检查是否启用了"Do not Disturb mode"



我正在构建一个实时流媒体移动应用程序,该应用程序要求在启动任何流媒体会话之前启用"请勿打扰模式"。如何使用Swift 4进行检查?

在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!")
}
}
}

相关内容

最新更新