Build a Custom Command
tip
Geocortex Mobile has many built-in Commands and Operations which can be chained together to build custom behaviors. If these Commands and Operations are not enough to accomplish your goal, you can use Geocortex Workflow to take custom behavior even further without writing custom code. If Workflow is still not enough to accomplish your needs, then it might be time to implement a Custom Command / Operation.
This article will walk you through implementing a custom command in Geocortex Mobile that displays an alert.
Prerequisites
Check out and setup the Geocortex Mobile SDK Quickstart project.
Create the Backing Service
It's convention that commands and operations in Geocortex Mobile are registered and implemented by a service or component, so the first thing we will do is create a service.
- Create a new file
Services/AlertService.cs
under the platform agnostic project.- In the file, add a new service class
AlertService
and register it with Autofac.
- In the file, add a new service class
- Create a class
Services/AlertOperations
under the platform agnostic project.- In the file, add a new class
AlertOperations
and register it with Autofac.
- In the file, add a new class
Implementing the Operation
Creating a new operation in Geocortex Mobile consists of two pieces:
- Defining the operation's name, inputs, and outputs in the
OperationsBase
class - Registering an execution implementation in the service.
- This function will be the actual code that executes when the operation is called.
Define the Operation
For this example, let's define a operation with some input and no output.
Register an Implementation for the Operation
Next, we need to register an implementation for our operation in the AlertService
.
- Add a public constructor that takes an
AlertOperations
to the Service.
- Create an implementation for displaying a custom alert and register it as an execution for the operation.
Congratulations! You just created your first custom operation. You can easily test your new operation by setting it to run it on map initialization.
Relevant SDK Samples
Check out the relevant Geocortex Mobile SDK Samples:
Next Steps
Commands and operations are the logical building blocks of executing custom behavior in Geocortex Mobile, but sometimes you need to take things a bit further. Creating custom components can allow you to design completely custom UI for Geocortex Mobile, and creating background services can enable the execution of tasks on an arbitrary schedule.
Commands and Operations
Learn more about commands and operations
Implement a Custom Component with UI
Learn how to implement a custom component using the Geocortex Mobile SDK
Implement a Custom Service
Learn how to implement a custom service using the Geocortex Mobile SDK