From df01d4b78818e4d57f860c366c7238301cdab8c7 Mon Sep 17 00:00:00 2001 From: gbattistel Date: Mon, 9 Dec 2024 16:54:15 -0300 Subject: [PATCH] feat: sync mute button state in CallView with call state when app enters foreground --- TelnyxWebRTCDemo/ViewController.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/TelnyxWebRTCDemo/ViewController.swift b/TelnyxWebRTCDemo/ViewController.swift index 3664f722..b7f764cb 100644 --- a/TelnyxWebRTCDemo/ViewController.swift +++ b/TelnyxWebRTCDemo/ViewController.swift @@ -76,6 +76,15 @@ class ViewController: UIViewController { self.telnyxClient = appDelegate.telnyxClient self.initViews() + // Register notifications + NotificationCenter.default.addObserver(self, + selector: #selector(appWillEnterForeground), + name: UIApplication.willEnterForegroundNotification, + object: nil) + } + + deinit { + NotificationCenter.default.removeObserver(self) } func initViews() { @@ -132,6 +141,11 @@ class ViewController: UIViewController { self.showHiddenOptions() } } + + @objc func appWillEnterForeground() { + print("ViewController:: App is about to enter the foreground") + self.callView.isMuted = self.appDelegate.currentCall?.isMuted ?? false + } func showHiddenOptions() { let alert = UIAlertController(title: "Options", message: "", preferredStyle: .actionSheet)