【发布时间】:2020-06-29 04:05:44
【问题描述】:
我正试图在用户离开视图时立即暂停 Twillio 呼叫,无论是被用户还是被任何中断(如接到另一个电话)。
func addObservers() {
NotificationCenter.default.addObserver(self,
selector: #selector(applicationDidBecomeActive),
name: UIApplication.didBecomeActiveNotification,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(applicationDidInActive),
name: UIApplication.didEnterBackgroundNotification,
object: nil)
}
func removeObservers() {
NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
}
@objc fileprivate func applicationDidBecomeActive() {
printLog(log: "=============applicationDidBecomeActive========")
holdCall(onHold: false)
}
@objc fileprivate func applicationDidInActive() {
printLog(log: "==============applicationDidInActive============")
holdCall(onHold: true)
}
在 android 中,相同的行为会以某种方式触发在后端注册到 trackUnsubscribed 的事件
room.on('trackUnsubscribed', function (track, participant) {
isJoin = true;
dePopulatScreen();
if ( $('#video-error').hasClass("display-view") ) {
$('#video-error').removeClass('display-view');
}
$('#video-error #supported div img').css('display', 'none');
document.getElementById('video-error-message').innerHTML = 'Call has been placed on hold by the patient. Please wait it will automatically reconnect shortly.'
detachTracks([track]);
});
如何在 ios 中实现同样的功能
【问题讨论】: