首页 > 解决方案 > 在iOS中检测“触摸返回通话”的点击

问题描述

有没有办法检测用户是否点击了“触摸返回通话”(https://i.stack.imgur.com/9m9xi.jpg)?也许是某种委托方法,或者像 inapplication(_:didFinishLaunchingWithOptions:)

标签: iosswiftcallkit

解决方案


class ViewController: UIViewController {

    private var observer: NSObjectProtocol?

    override func viewDidLoad() {
        super.viewDidLoad()

        observer = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { [unowned self] notification in
            // do whatever you want when the app is brought back to the foreground
        }
    }
}

只需在您调用Kit viewcontroller 类中的此代码,并通过点击“触摸以返回通话”来检查用户何时返回应用程序


推荐阅读