0

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?

user3004499
  • 189
  • 3
  • 3
    Does this answer your question? [How can I detect DND mode within an app?](https://stackoverflow.com/questions/17560765/how-can-i-detect-dnd-mode-within-an-app) – Alexey Lysenko Mar 15 '20 at 11:40

1 Answers1

3

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:

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

        }
    }
}
Chase Smith
  • 168
  • 7