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,348 times
-1
-
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
- 148
- 6