Objective model
Objective model it’s high-level abstraction layer around library’s API.
Key reasons of using model
Model contains cumulative state of the dialing part of the app
Library’s API is designed to be abstract and universal. Adding set of getters which provides low levels details, like listed below, would made it overcomplicated.
In the same time model uses API of library and can much easier store and manipulate with details valuable for particular application. As example model can easily resolve requests like:
How many accounts/calls exists?
Which is the state of account/call?
Which account selected as default for outgoing calls?
Were some dtmf tones sent/received by the call?
etc…
Model can serialize (save and restore call/accounts data);
As a consequence of the above, model can store/load its data when it’s required and using best matched format for the application.
Model can have access to list of contacts and resolve contact name, which matches phone number of the call;
Model and API can be updated independently.
Model is part of the application and developers can modify it as required. It hides library API from the application. When added or modified some API methods will be enough to modify only model implementation.
Model is easy to use for UI implementation. Each time when state of the model changed it notifies app to update UI. Same notification can be handled by multiple applications parts.
Object diagram
Here is example of possible model implementation:
How it works
*1, *2 - model can update its state and trigger UI updates few times. First - just after invoking API method to display intermediate state like: registering, dialing, canceling, etc. Second - when handles event, received from API, to display updated state like: registered, connected, terminated, etc.
Models provided with example applications
Siprix team has prepared models as part of the example applications which are available on GitHub:
Flutter (all supported platforms) FlutterPlugin. See also Own models implementation
Java (Android). Folder
modelin example application SampleJavaSwift (iOS).
SiprixModels.swiftin example application SampleSwiftUI. Includes CallKit.C# (Windows)
SiprixModels.csin example application SampleWpf
Models from these applications can be reused, modified, extended as it’s required by end user.