Getting a WebcomApplication
The first thing you need to work with this SDK is a WebcomApplication
instance,
which then allows you to use the Authentication service (see: WebcomApplication.authenticationService
)
and the Datasync service (see: WebcomApplication.datasyncService
).
A WebcomApplication
instance corresponds to an application created on the Webcom back-end.
To create such an application, go to the Webcom console.
The main initializer WebcomApplication.init(configuration:)
needs a WebcomConfiguration
argument,
which identifies the back-end application to use and optionally gives additional parameters.
Only from Code
You can provide a WebcomConfiguration
directly in you code.
At a minimum, you must provide the identifier (see: WebcomConfiguration.identifier
).
You can also specify the cache mode (see: WebcomConfiguration.cacheMode
).
Using Info.plist
File
You can also configure your WebcomConfiguration
instances in the Info.plist
file of your target, by adding a Webcom
property in it.
Single Configuration
If you need only one WebcomConfiguration
instance, this property can be a Dictionary
with the following content:
Key | Status | Type | Allowed Values | Default Value | Description |
---|---|---|---|---|---|
▼ Webcom |
Dictionary |
root key for Webcom parameters | |||
identifier |
mandatory | String |
valid identifier | no default value | identifier of the Webcom application on the back-end |
key |
optional | String |
any string | no default value | local key to retrieve this configuration |
platform |
optional | String |
valid URL | https://io.datasync.orange.com | URL of the back-end platform to use |
cacheMode |
optional | String |
no , initialized , manualSaving or automatic |
no |
cache mode for the Datasync service |
cacheData |
optional | String |
valid data | no default value | initial cache data to load when cacheMode is initialized |
authStorage |
optional | String |
default , key , share |
default |
defines how authentication state is shared between webcom applications |
authStorageKey |
optional | String |
any string | no default value | defines storage key when authStorage is key |
▼ webSocket |
optional | Dictionary |
no default value | configuration for the web socket used by the Datasync service | |
protocol |
optional | String |
v5 or v6 |
v5 |
version of the protocol |
keepAliveDelayMS |
optional | Int |
any integer | back-end default value | maximum delay between two consecutive messages, in milliseconds |
pongDelayMS |
optional | Int |
any integer | back-end default value | maximum delay to receive acknowledgement for ping messages, in milliseconds |
Then, you can get the corresponding WebcomApplication
instance using the Webcom.defaultApplication
property.
Multiple Configurations
If you need several distinct WebcomConfiguration
instances, this property must be an Array
whose items are Dictionary
values containing the same properties as above.
For example:
Key | Type | Value |
---|---|---|
▼ Webcom |
Array |
(2 items) |
▼ Item 0 |
Dictionary |
(3 items) |
identifier |
String |
EmployeeDirectory |
key |
String |
employees |
cacheMode |
String |
automatic |
▼ Item 1 |
Dictionary |
(2 items) |
identifier |
String |
ConfigurationParameters |
key |
String |
configuration |
The SDK provides facilities to handle such collections of WebcomConfiguration
values.
To instantiate an array from the Info.plist
file, you use the Webcom.defaultConfigurations
property.
You can get a specific WebcomConfiguration
instance:
- using its
identifier
with theCollection.application(withIdentifier:)
method, e.g.Webcom.defaultConfigurations.application(withIdentifier: "EmployeeDirectory")
, - using its
key
with theCollection.application(withKey:)
method, e.g.Webcom.defaultConfigurations.application(withKey: "employees")
.
More simply, you can get the WebcomApplication
instance corresponding to the first configuration
(the one with the EmployeeDirectory
identifier and the employees
key in the example)
using the Webcom.defaultApplication
property.
Tips: The key
parameter is specially useful when you have several configurations with the same identifier on distinct platforms.