简体   繁体   English

如何使用 Swift 4 检查是否启用了“请勿打扰模式”

[英]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.

相关问题 您可以在iOS 8(带有Swift)中以编程方式切换“请勿打扰”模式吗? - Can you programmatically toggle Do Not Disturb mode in iOS 8 (w/ Swift)? 如何在 iOS swift 中以编程方式打开/关闭 DND“请勿打扰”模式 - how to turn On/Off DND “Do not Disturb” Mode programmatically in iOS swift 如何检查iOS设备是否设置为“请勿打扰”? - How do I check if iOS device is set to “do not disturb”? 如何检查 iOS/iPadOS 中是否启用了暗模式? - How can I check whether dark mode is enabled in iOS/iPadOS? 如何在请勿打扰模式下播放 UILocalNotification 声音? - How to play UILocalNotification sound while do not disturb mode is on? 即使启用了“请勿打扰”设备,如何为 VoIP 推送呼叫显示传入的 CallKit window? - How to show incoming CallKit window for VoIP push call even if the device “Do not Disturb” is enabled? 如何在Swift中使用XCAssert检查isViewLoaded? - How can I check isViewLoaded using an XCAssert in Swift? 如何检查 iOS 设备上是否启用了 Motion & Fitness? - How can I check whether or not Motion & Fitness is enabled on an iOS device? 如何检查是否启用了特定类型的本地通知? - How can I check if a specific type of local notification is enabled? 如何检查解析中的课程? -迅捷 - How do I check a class in parse? - Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM