5 Replies
      Latest reply on Oct 27, 2019 5:57 AM by eskimo
      Remastered21 Level 1 Level 1 (0 points)

        We're working on a VoIP app using Zoom SDK. The app is able to receive incoming call and show system calling screen using CallKit in any state (background, foreground, suspended, terminated).

         

        The problem is the timer function that needs to start running after notification is received. Whenever the app is woken back up from sleep of force-quit, my timer function doesn't run, which is a critical piece to terminate the call automatically if the user can't pick up the call. We've tried calling the timer in the main queue, but no luck so far.

         

        Is there a way to start to timer as soon as app receives VoIP notification and wake up?

        • Re: Unable to get Timer running after waking the app up from force-quit state using VoIP notificaiton
          eskimo Apple Staff Apple Staff (12,305 points)

          How are you scheduling that timer?  How long is it scheduled for?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Unable to get Timer running after waking the app up from force-quit state using VoIP notificaiton
              Remastered21 Level 1 Level 1 (0 points)
              self.provider?.reportNewIncomingCall(with: self.callUUID!, update: update, completion: { (error) in
                if error != nil {
                }
              
                if isIncoming { // incoming call
                     if !self.shouldReceiveCall {
                          let transaction = CXTransaction(action: CXEndCallAction(call: self.callUUID!))
                          self.callController?.request(transaction, completion: { error in })
                          return
                     }
              
                     let appDelegate = UIApplication.shared.delegate as! AppDelegate
                     if (appDelegate.window?.visibleViewController() as? SplashViewController) != nil {
                          self.isSplashLoading = true
                          return
                     }
              
                     self.isSplashLoading = false
                     self.isIncomingCall = true
              
                     self.expireTimer = Timer.scheduledTimer(timeInterval: kExpireCallCheck,
                     target: self,
                     selector: #selector(self.checkExpireCall),
                     userInfo: nil,
                     repeats: false)
                }
                else { // call rejected
                self.provider?.reportCall(with: self.callUUID!, endedAt: nil, reason: .unanswered)
              
                DispatchQueue.main.async {
                     let appDelegate = UIApplication.shared.delegate as! AppDelegate
                          if let vc = appDelegate.window?.visibleViewController() as? CallScreenViewController {
                          vc.endCall()
                          }     
                     }
                }
              })
              
              

              Line 21 through 26 Is the Timer.

              kExpireCallCheck (timer) is set for 60 seconds.

               

              Basically, once the app is woken up and is in the process of receiving an incoming VoIP call, we want to fire up the timer so that after 60 seconds we can reject the call. We're can't get the timer to fire up.