2
CallKit
でコールを受信してから12秒後にタイムアウトTimer
を追加しようとしましたが、アプリがバックグラウンドのときに解雇されません。Appdelegate
私のコード:時間の経過後のコールタイムアウト機能
self.callBackgroundHandlerIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: {
UIApplication.shared.endBackgroundTask(self.callBackgroundHandlerIdentifier!)
self.callBackgroundHandlerIdentifier = UIBackgroundTaskInvalid
})
DispatchQueue.global(qos: .userInitiated).async {
AppDelegate.callAnswerTimer = Timer.scheduledTimer(timeInterval: 12, target: self, selector: #selector(AppDelegate.hangUpOnCallTimeOut), userInfo: nil, repeats: false)
self.callBackgroundHandlerIdentifier = UIBackgroundTaskInvalid
}
func hangUpOnCallTimeOut(){
AppDelegate.timeOutTimer?.invalidate()
AppDelegate.timeOutTimer = nil
if #available(iOS 10.0, *) {
ProviderDelegate.sharedInstance.endCall(uuids: ApplicationDelegate.activeCalls!) { (uuid) in }
}
if self.callBackgroundHandlerIdentifier != UIBackgroundTaskInvalid {
UIApplication.shared.endBackgroundTask(self.callBackgroundHandlerIdentifier!)
}
}
私が間違っていることは何ですか?