Services act as a repository of accessible behavior and data, and can be used for a variety of purposes, from implementing commands and operations, to managing shared data, to interfacing with the REST API of an external service.
All services need to be registered with Geocortex Mobile. A service is created by extending the
ServiceBase class and registering the service class with Autofac through an assembly attribute.
On application load, all services that have been registered with wih Geocortex Mobile are first created and then initialized.
Services are destroyed (i.e. the
_onDestroy method is invoked) when the application is destroyed, e.g. when killing the application or switching applications in Geocortex Go.
Services have an initialization method, which can be used to perform asynchronous startup logic, and a teardown method, which can be used to free resources when the application is destroyed.
base.Dispose(disposing) when overriding the
ServiceBase already implements
IDisposableTracker, so only override the
Dispose method if you have created new managed resources which need to be cleaned up.
Services interact with the larger application by injecting their dependencies. Services can inject commands and operations, other services, and any other class registered with Autofac.
The following example injects the UI operations and the dialog controller into a custom service.
Services are not intended to directly interact with each other. Instead, services should implement operations which can be called by other services to indirectly interact.
Each item type in the application is bound to a class registered as an
AppItem with autofac. This class instantiates itself with values from the app config in its constructor, acting as a configuration model.
A service can consume configuration by injecting the
AppItem class as a dependency in its constructor.
- Service Configuration Model
- App Config
Check out the relevant Geocortex Mobile SDK Samples:
Learn how to use Commands and Operations with Services
Learn how to run and implement commands and operations with custom services
Learn about Service Interactions
Learn about how services and components can interact
Build a Custom Command with a Custom Service
Follow a step by step guide to building a custom command with a custom service
Build a Service that Manages Dynamic Data
Built a service that manages a dynamic data source and exposes it to components