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:
- Opening in Default Browser: Recommended approach that opens the incident reporting page in the device's default browser
- Getting URL for In-App Browser: Alternative approach for apps that already have required permissions mentioned in this section
Prerequisites
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
- 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
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:
| Error | Description | Solution |
|---|---|---|
LeeoErroCode.SDK_NOT_SETUP | SDK not properly initialized | Call FairmaticSDK.setup() first |
LeeoErroCode.NETWORK_NOT_AVAILABLE | Check internet connectivity and retry | |
LeeoErroCode.INCIDENT_REPORTING_FEATURE_NOT_ENABLED | The incident reporting feature is not enabled for the organization | Please contact Leeo support team with your SDK key |
Best Practices
- Use Default Browser First: Always prefer
openIncidentReportingWebPageunless you specifically need in-app browsing - Don't Cache URLs: Always fetch a fresh URL when using
getIncidentReportingURL