Unable to get Timer running after waking the app up from force-quit state using VoIP notificaiton

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?

Replies

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"
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.

Is this problem new in iOS 13?

Also, what did you pass to the

queue
parameter of setDelegate(_:queue:).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Well, I can't say it's strictly a problem with the new iOS because we made the transition from QuickBlox to Zoom for the VoIP protion of our app right as the iPhones started to make transition to iOS 13. We had success of waking the app up and have the timeout for rejecting calls work properly when working with QuickBlox, but even then it was slightly shaky.


I've talked to one of our developers and he says we're passing `nil` for queue parameter, because provider’s delegate will be main queue by default (edited) if nil is passed on.

Well, I can't say it's strictly a problem with the new iOS

OK. iOS 13 has a number of changes that affect VoIP apps, the most critical of which is the requirement to respond to VoIP pushes by creating a CallKit call, as announced in WWDC 2019 Session 707 Advances in App Background Execution. However, this shouldn’t directly affect this issue.

I've talked to one of our developers and he says we're passing

nil
for queue parameter, because provider’s delegate will be main queue by default (edited) if nil is passed on.

Cool. Anything else would be problematic because timers like this are scheduled on the current thread’s run loop.

Alas, that’s me out of ideas as to what’s going wrong. My recommendation is that you open a DTS tech support incident and talk to our VoIP expert.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"