Responding to Cellular Call Events
Dispatched when the call state changes.
Declaration:
var callEventHandler: ((CTCall!) -> Void)!
Discussion:
This property block object is sent to the default global priority queue when the call state changes. To handle such call events, define a handler block in the application and assign it to this property. You must implement a handler block to support a call from any context.
If your application is active when a call event occurs, the system sends the event to your handler immediately. However, call events can also occur while the application is paused. While it is paused, your application does not accept call events. When your application resumes an active state, it receives one call event for each call that changed state, regardless of how many states the call changed when your application was suspended. A single call event sent to your handler, after your application returns to its active state, describes the state of the calls at that time.
For example, suppose your application changes from active to suspended when the call is in a connected state. Suppose also that while your application is paused, the call is disconnected. When your application returns to active state, you receive a cellular call event indicating that the call is disconnected.
Here is a more complex example. Suppose that your application has changed from active to suspended after the user initiated the call, but before it is connected (i.e. your application is suspended when the call is in dialing state). Suppose further that while your application is paused, the call first switches to the connected state and then to the disconnected state. When your application returns to active state, you receive one cellular call event indicating that the call is disconnected.
Perhaps now you can understand how to declare it.