Work with GPS data in Mobile Creatio
Use GPS functionality in Mobile Creatio to retrieve real-time latitude and longitude data directly from the mobile app as well as gain deeper insights using additional GPS-related information, for example, accuracy, permissions, mock location detection.
To work with GPS data in Mobile Creatio, implement a custom request handler using remote module. Learn more: Custom request handler implemented using remote module in Mobile Creatio. Requires using the GeolocationService
service that returns current location using the getCurrentCoordinates()
method. Learn more: GeolocationService service.
To call the request handler, use the Button component added to the Freedom UI page in the Mobile Creatio. Learn more: Button.
1. Create a TypeScript project
Instructions: Create a TypeScript project.
2. Create a custom request
Instructions: Create a custom request.
3. Create a custom request handler
Instructions: Create a custom request handler.
View the example that uses the GeolocationService
service while implementing a request handler below.
/* Import the required functionality from the libraries. */
import {
BaseRequest,
CrtRequest,
BaseRequestHandler,
CrtRequestHandler
} from "@creatio/mobile-common";
/* Add the "CrtRequest" decorator to the "SomeRequestNameRequest" class. */
@CrtRequest({
type: 'usr.SomeRequestNameRequest'
})
export class SomeRequestNameRequest extends BaseRequest {}
/* Add the "CrtRequestHandler" decorator to the "SomeRequestNameHandler" class. */
@CrtRequestHandler({
requestType: 'usr.SomeRequestNameRequest',
type: 'usr.SomeRequestNameHandler',
scopes: ['MobileFUIActivityRecordPageSettingsDefaultWorkplace'],
})
export class SomeRequestNameHandler extends BaseRequestHandler<SomeRequestNameRequest> {
public async handle(request: SomeRequestNameRequest): Promise<unknown> {
const coords: GeolocationServicePosition = await new GeolocationService().getCurrentCoordinates(GeolocationAccuracy.low);
/* Implement a custom business logic to process data of current location. */
...;
return this.next?.handle(request);
}
}
4. Add the custom request handler to the Freedom UI page
Instructions: Add the custom request handler to the Freedom UI page.
As a result, Mobile Creatio will return current location when you click the button.
See also
Custom request handler implemented using remote module in Mobile Creatio