Skip to main content

Incident reporting

The Leeo SDK provides APIs that the client application can call to start the incident reporting flow. The driver can use this flow to report any incidents and record related details when they are performing duties.

Overview

The Leeo SDK offers two main methods for incident reporting:

  1. Opening in Default Browser: Recommended approach that opens the incident reporting page in the device's default browser
  2. Getting URL for In-App Browser: Alternative approach for apps that already have required permissions mentioned in this section

Prerequisites

Important

Make sure you have set up the SDK using the FairmaticSDK.setup() method before calling any incident reporting methods, otherwise you will receive a FairmaticErrorCode.SDK_NOT_SETUP error.

SDK Methods

1. Open Incident Reporting Web Page

Opens the incident reporting web page in the device's default browser. This is the recommended approach as it allows users to grant the required permissions to the browser instead of your app.

setLoading(true) // Show a loader as the method can take some time to open the browser
FairmaticSDK.openIncidentReportingWebPage()
.then((result: FairmaticOperationResult) => {
if (result.isSuccess) console.log("Incident reporting page opened");
else
console.log(
"Failed to open incident reporting page because of ",
result.errorMessage
);
})
.catch((error: any) => {
console.error("Error opening incident reporting page:", error);
})
.finally(() => {
setLoading(false) // Hide the loader after the method completes
console.log("openIncidentReportingWebPage call completed");
});

When to Use

  • When your app doesn't have camera, microphone, speech transcription, or location permissions
  • For the best user experience (recommended approach)
  • When you want to avoid requesting sensitive permissions in your app

2. Get Incident Reporting URL

Returns the URL of the incident reporting web page that can be used to open the page in an in-app browser or webview.

setLoading(true) // Show a loader as the method can take some time to open the browser
FairmaticSDK.getIncidentReportingURL()
.then((result: IncidentReportingURLResult) => {
// If the result is string, it means the URL was successfully retrieved
if (typeof result === "string") {
console.log("Incident reporting URL:", result);
} else {
console.log(
"Failed to get incident reporting URL because of ",
result.errorCode
);
}
})
.catch((error: any) => {
console.error("Error getting incident reporting URL:", error);
})
.finally(() => {
setLoading(false) // Hide the loader after the method completes
console.log("getIncidentReportingURL call completed");
});

Important Notes

URL Validity
  • The URL returned is valid only for a limited time
  • Do not cache or store the URL for long-term use
  • Fetch a new URL each time you need to open the incident reporting page
Permissions

To open the URL in your app, it should have related permissions granted. If the app doesn't have necessary permissions, it might exhibit runtime crashes when the incident reporting web page tries to execute the functionality related to these permissions.

For detailed info on the needed permissions, please refer individual Android and iOS sections.

Error Handling

Common errors you might encounter:

ErrorDescriptionSolution
LeeoErroCode.SDK_NOT_SETUPSDK not properly initializedCall FairmaticSDK.setup() first
LeeoErroCode.NETWORK_NOT_AVAILABLECheck internet connectivity and retry
LeeoErroCode.INCIDENT_REPORTING_FEATURE_NOT_ENABLEDThe incident reporting feature is not enabled for the organizationPlease contact Leeo support team with your SDK key

Best Practices

  1. Use Default Browser First: Always prefer openIncidentReportingWebPage unless you specifically need in-app browsing
  2. Don't Cache URLs: Always fetch a fresh URL when using getIncidentReportingURL