title: cancel incoming call when the caller stop it
body: <p>I want to stop callkit notification in incoming call after the caller is canceled and the receiver has not answered yet so I received that the user canceled the call by another pushkit notification that has a missingCall key.
  the problem is that the first try to cancel a call from the caller is a success and the callkit notification is stopped but after that, any call is not canceled until I terminate the app totally and the same thing happen only first-time success</p>
  <p>this is the code</p>
  <pre><code>func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -&gt; Void) {
      print(&quot;didReceiveIncomingPushWith payload&quot;)
      
      let payloadDictionary = payload.dictionaryPayload as NSDictionary
      callOption.callData = payloadDictionary.value(forKey: &quot;aps&quot;) as! [String : Any]
      let user = callOption.callData[&quot;user&quot;] as! [String  : Any]
      let callerID = user[&quot;name&quot;] as! String
      let hasVideo  = true 
      let callUpdate = CXCallUpdate()
      let uuid = UUID()
      callUpdate.remoteHandle = CXHandle(type: .generic, value: callerID)
      callUpdate.hasVideo = hasVideo
            DispatchQueue.global().async {
          self.callOption.ringingApi(otherId: self.callOption.callData[&quot;snd_id&quot;] as! String)
      }
  
      let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
      if callOption.callData[&quot;typeCall&quot;] as! String == &quot;missingCall&quot; {
          self.endIncomingCall(userId: callOption.callData[&quot;snd_id&quot;] as! String)
          UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
          
      }
      else {
          self.displayIncomingCall(uuid: uuid, handle: callerID, hasVideo: hasVideo, userId: callOption.callData[&quot;snd_id&quot;] as! String) { _ in
                         UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
                     }
      }
  
  }
  </code></pre>
  <p>here the functions that called above</p>
  <pre><code> func displayIncomingCall(uuid: UUID, handle: String, hasVideo: Bool, userId: String, completion: ((NSError?) -&gt; Void)? = nil) {
      providerDelegate?.reportIncomingCall(uuid: uuid, handle: handle, hasVideo: hasVideo, userId: userId, completion: completion)
      }
  func endIncomingCall( userId: String) {
      providerDelegate?.reportTheCallerEndCall( userId: userId)
      }
  </code></pre>
  <p>and this is the provider delegate</p>
  <pre><code> /// Use CXProvider to report the incoming call to the system
  func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool, userId: String, completion: ((NSError?) -&gt; Void)? = nil) {
         // Construct a CXCallUpdate describing the incoming call, including the caller.
         let update = CXCallUpdate()
         update.remoteHandle = CXHandle(type: .phoneNumber, value: handle)
         update.hasVideo = hasVideo
         provider.reportNewIncomingCall(with: uuid, update: update) { error in
         
             if error == nil {
                 let call = Call(uuid: uuid, handle: handle, userId: userId)
                 
  
                 self.callManager.add(call: call)
             }
             
             completion?(error as NSError?)
         }
     }
  
  func reportTheCallerEndCall(userId: String) {
      guard let callIndex = self.callManager.findCallIndexInCallsArray(userId: userId) else { return}
      provider.reportCall(with: self.callManager.calls[callIndex].uuid, endedAt: nil, reason: .unanswered)
  }
  </code></pre>