简体   繁体   English

UIApplication.shared.open, swift 完成一个连接处理

[英]UIApplication.shared.open , swift completion of a connection handling

The below code is used to open a face time and establish a connection, but how to do a certain operation once the call is ended, the "completionHandler" is used only to know if the connection is establised or not下面的代码是用来打开一个face time并建立一个连接,但是一旦调用结束后如何进行某个操作,“completionHandler”只是用来知道连接是否建立

UIApplication.shared.open(url, options: [:],completionHandler:nil)

like喜欢

UIApplication.shared.isClosed() UIApplication.shared.isClosed()

The URL opened is facetime URL打开的URL是facetime URL

It is not possible to know the state of a third-party app (facetime in your case) if you're the developer of that app you could probably create an app group to store some info about the app state and, as far as I know, FaceTime doesn't have public APIs.如果您是该应用程序的开发人员,则不可能知道第三方应用程序的 state(在您的情况下为 facetime),您可能可以创建一个应用程序组来存储有关应用程序 state 的一些信息,据我所知知道,FaceTime 没有公共 API。

A workaround in your case would be to observe when your app is in foreground again and do your stuff .在您的情况下,一种解决方法是观察您的应用程序何时再次处于前台并执行您的操作

You can use AppDelegate's methods:您可以使用 AppDelegate 的方法:

or you can observe those notifications或者你可以观察那些通知

Here's an example of how your view controller would look like这是您的视图 controller 的示例

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive),
                                               name: UIApplication.didBecomeActiveNotification,
                                               object: nil)
    }

    private func openFaceTime() {
        guard
            let faceTimeURL = URL(string: "facetime://user@example.com")
            else { return }
        UIApplication.shared.open(faceTimeURL, options: [:], completionHandler: nil)
    }

    @objc private func appDidBecomeActive() {
        // do your stuff
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UIApplication.shared.open 仅适用于 https - UIApplication.shared.open only works with https UIApplication.shared.open添加标题数据 - UIApplication.shared.open Add Header Data UIApplication.shared.open 在 ios 13 中不起作用 - UIApplication.shared.open is not working in ios 13 UIApplication.shared.open(url) 算作加密吗? - Does UIApplication.shared.open(url) count as encryption? UIApplication.shared.open(_ url:URL等)没有打开任何东西 - UIApplication.shared.open(_ url: URL,etc.) doesn't open anything Gmail 有没有办法从 UIapplication.shared.open url 的文本中识别换行符 - Is there a way for Gmail to recognize line breaks from text from UIapplication.shared.open url 用户通知接收响应方法是否允许我将更新的变量传递给UIApplication.shared.open()? - User-Notification Did Receive Response Method Does not allow me to Pass Updated Variable to UIApplication.shared.open() ? iOS 14.5 或 14.6 及更高版本访问共享扩展中的 UIApplication.shared.open 或 UIApplication.shared.openURL 给出“APPLICATION_EXTENSION_API_ONLY” - iOS 14.5 or 14.6 onwards accessing UIApplication.shared.open or UIApplication.shared.openURL in Share Extension gives "APPLICATION_EXTENSION_API_ONLY" Swift - 从主线程访问 UIApplication.shared.statusBarOrientation - Swift -access UIApplication.shared.statusBarOrientation from main thread 使用UIApplication.shared.keyWindow?.addSubview快速将自定义视图添加到屏幕 - Swift add Custom View to screen with UIApplication.shared.keyWindow?.addSubview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM