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
UIApplication.shared.open(url, options: [:],completionHandler:nil)
like
UIApplication.shared.isClosed()
The URL opened is 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.
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:
applicationWillEnterForeground(_ :)documented hereapplicationDidBecomeActive(_:)documented hereor you can observe those notifications
willEnterForegroundNotificationdocumented heredidBecomeActiveNotificationdocumented hereHere's an example of how your view controller would look like