For every Execution Task, a corresponding pre-coded module is expected in the app as part of SDK. This module executes the Task on the device running the Delivery Agent app. Thus, the Dispatcher SDK allows you to build this app with the minimum amount of effort.
The Mobile App SDK will orchestrate the execution of Tasks. Objective status updates will flow back as objective events to dispatch service through API calls made by the SDK and they will be stored in the Objective Events Store. This SDK can be used to render execution task screens on UI, maintain their states, and manage Motion Tracking System.
Dispatch SDK is an expo-based SDK that is written in Typescript and some Modules in Java/Kotlin.
Currently supports SDK>=21 (Android).
- Sync Manager: Provides Sync Manager for syncing events & Docs in the background with retry functionality.
- Execution Tasks: Provides a list of Execution Tasks which are as follows: Deliver, Capture Input, Deliver Cash, Complete-Success, Complete-Failure, Pickup, Doodle, Forms, Display, Verify Location, Verify OTP, Verify String, Scan QR/Barcode, Image Capture, Init Payment, Process Payment, and Complete Payment.
- Execution Engine: Provides methods for Executing a given Workflow/Job in a dispatch.
- Firebase Cloud Messaging: Provides a method for receiving Firebase Cloud Messaging.
- Async Storage: Provides async storage for storing key-value pairs.
- Higher-Order ETs: Provides a way to customize Execution Task UI.
- Asynchronous Event Handling: Provides a method for handling Execution Tasks asynchronously.
Add the following line in gradle.properties file for increasing storage (AsyncStorage_db_size_in_MB=10)
Add jcenter() if not added already added in the Project-level build.gradle (/build.gradle): (Android only)
Add the following changes in the metro.config.js file. Issue Link
Add the Firebase Android configuration file to your app:
- Create a Firebase project (Check Firebase instructions for creating an app).
- Click Download google-services.json to obtain your Firebase Android config file (google-services.json).
- Move your config file into the module (app-level) directory of your app.
- To enable Firebase products in your app, add the Google services plugin to your Gradle files.
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.
Register a callback for receiving FCM Messages in the background.
Call this function in the root component, i.e, in the `index.js file of the app.
useFcmMessage() custom hook in functional components to receive FCM Messages in Foreground.
Extend FCM base class in case of class components
In the case of the dispatch mobile app, the Location Tracking module of the SDK provides a configurable way to capture and stream location data from the mobile device to the MTSservice, without any user intervention. To learn more, see Dispatch Documentation.
The Dispatch SDK support handling Execution Tasks asynchronously by emitting two events for each ET. This lets your apps to listen to these events and perform necessary actions.
For every ET, two events will be triggered in a fire-and-forget mode:
- Task Start event: Triggered upon arrival of the ET, along with input data
- Task End event: Triggered just before moving to the next ET, with the output data of objectives executed in that ET and the ID of the next ET to be executed.
To use this feature, you need to work with the eventListener method, which is used to listen and remove events. It contains the following methods:
- .on: To listen to a specific event
- .remove: To remove a specific event
See the examples below to describe event payloads using a CaptureImage Event
Triggered before starting the execution of ET
Triggered after the completion of ET and before moving to the next ET.
Triggered when goBack is executed for an ET, before moving to the next ET.