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?
Asked
Active
Viewed 1,993 times
0
-
3Does 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 Answers
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
-
1
-
@J4L0O0L It appears to be a string representing the name of the handle: https://developer.apple.com/documentation/callkit/cxhandle/2102570-init – Darrell Brogdon May 29 '23 at 19:41