 
     func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
         listeners.forEach {
-            $0.listener?.performSetMutedCall?(UUID: action.callUUID, isMuted: action.isMuted)
+            let listener = $0 as! JMCallKitListener
+            listener.performSetMutedCall?(UUID: action.callUUID, isMuted: action.isMuted)
         }
 
         action.fulfill()


    func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
        listeners.forEach {
            $0.listener?.performEndCall?(UUID: action.callUUID)
        }

        action.fulfill()


internal final class JMCallKitEmitter: NSObject, CXProviderDelegate {

    private let listeners = NSMutableArray()

    internal override init() {}

    // MARK: - Add/remove listeners

    func addListener(_ listener: JMCallKitListener) {
        if (!listeners.contains(listener)) {
            listeners.add(listener)
        }
    }

    func removeListener(_ listener: JMCallKitListener) {
        listeners.remove(listener)
    }

    // MARK: - CXProviderDelegate

    func providerDidReset(_ provider: CXProvider) {
        listeners.forEach {
            let listener = $0 as! JMCallKitListener
            listener.providerDidReset?()
        }
    }

    func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
        listeners.forEach {
            let listener = $0 as! JMCallKitListener
            listener.performAnswerCall?(UUID: action.callUUID)
        }

        action.fulfill()
