In-app feedback for Android apps
In-app feedback enables you to ask for feedback from your users. App users can then attach and annotate images/screenshots, include logs and diagnostics, or report a bug while sharing a feedback. It comes with an in-built annotator that helps app users mask any sensitive information, scribble on the screenshots, or add arrows to pinpoint the areas with issues.
By default, feedback uses WorkManager to sync the feedback with the Apptics server. WorkManager initialization is taken care of by the jetpack library automatically. In scenarios, where the WorkManager initialization fails, the Foreground service is used as an alternate.
Add the SDK
- Before your begin, make sure that Apptics is integrated into your project by following the Integration Guide.
- Declaring in-app feedback dependency using Apptics BoM.
Copieddependencies {
// ...
// Apptics BoM, latest version is mentioned in the integration guide.
implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
// Since BoM version is specified, no need to explicitly specify the dependency version.
implementation 'com.zoho.apptics:apptics-feedback'
}
- If you do not use Apptics BoM you can directly declare the in-app feedback dependency with its version.
Copieddependencies {
// Have to explicitly mention the version, if you are not using BoM.
// latest version is mentioned in the integration guide.
implementation 'com.zoho.apptics:apptics-feedback:[latest-version]'
}
Note: It is recommend to use Apptics BoM to avoid unnecessary compatibility issues.
- Initialize in-app feedback SDK in application onCreate() method.
CopiedApptics.init(this)
Feedback notification
The app users (above Android 13) have to explicitly enable the notifications in settings. If the notifications are disabled, the users are not shown any notifications for feedback. This is available only when you use the Foreground service.
There are two types of notifications that are displayed in the notification drawer.
- Success - `Feedback sent successfully` is shown in the notification drawer if the feedback was sent without any issues.
- Failure - 'Feedback sending failed' and `Retry` button is displayed in the notification drawer. If the user performs the swipe gesture and cancels the failure notification (ideal android behaviour), sending feedback will not be retried.
- A default feedback icon option is provided. Unless you change it, the default option will be used.
Shake for feedback
The Feedback/report bug prompt will be shown when the user shakes the device with the app in the foreground.
- Use the below method to turn off shake for feedback.
CopiedAppticsFeedback.disableShakeForFeedback()
- Use the below method to turn on shake for feedback.
CopiedAppticsFeedback.enableShakeForFeedback()
- Use the below method to know the current state of shake for feedback
CopiedAppticsFeedback.isShakeForFeedbackEnabled()
You can optimize the shake detection parameters like the number of shake counts before showing the prompt and shake velocity. Use the below method to optimize shake detection parameters.
CopiedAppticsFeedback.setShakeDetectionParams(2f, 3)
- Use the below callback to show your custom prompt on detecting shake.
CopiedAppticsFeedback.onShakeCallback = { activity ->
// build and show your custom shake prompt
}
Show feedback screen
You can also explicitly present the feedback screen to users on-demand. Use the below method to present the feedback screen.
CopiedAppticsFeedback.openFeedback(hostActivity)
Show report bug screen
Use the below method to automatically capture the screenshot and present annotation activity for reporting bug.
CopiedAppticsFeedback.reportBug(hostActivity)
- An app user can share the feedback/report a bug with their email id or can share it anonymously. If the user opts to share the feedback/report a bug anonymously then an alert is displayed on the screen. The alert will inform the user that if the feedback/report a bug is shared anonymously, app developers will not be able to contact them with solutions to the raised issues.
- You need to disable showing the alert on choosing anonymous explicitly. By default, it is enabled.
- The feedback screen/report a bug screen can be used both in portrait and landscape mode.
- Set the below method to true to enable an alert message when a user is in anonymous mode. If you set it to false user won't be notified with the anonymous alert message.
CopiedAppticsFeedback.enableAnonymousUserAlert()
Disable anonymous feedback reports
Use the below method to hide the anonymous option in the feedback screen. This will force the user to use the id while sharing the feedback.
CopiedAppticsFeedback.isAnonymousOptionNeeded = false
Headless feedback
Headless feedback allows you to use your own custom interface while using Apptics' feedback toolkit. There are two methods that can be used for sending headless feedback.
sendfeedback :
- This is a fire-and-forget method to send feedback. It uses WorkManager to sync the feedback with the Apptics server. This method has an inbuilt retry mechanism.
- This works in tandem with the user consent preference set in the app at the time of calling this method.
- A user can attach up to five images while sharing the feedback. The images can be attached only from the app's cache directory.
Note: If WorkManager is disabled, the above method will fail and the feedback won't be sent.
CopiedAppticsFeedback.sendFeedback(
type = AppticsFeedback.Type.FEEDBACK,
feedbackMessage = "Feedback Message",
includeDiagnostics = true,
includeLogs = true
)
sendFeedbackInstantlyWithoutRetries :
- This method will return the feedback status. It should be called from the workerThread.
Note: This method will fail if it is called via the UI Thread and the app will crash.
- This works in tandem with the user consent preference set in the app at the time of calling this method.
- A user can attach up to five images while sharing the feedback. The images can be attached only from the app's cache directory.
Note: if forceToAnonymous is set as true, the feedback will be shared anonymously and will override the user consent preference of the app.
Copiedval feedbackStatus = AppticsFeedback.sendFeedbackInstantlyWithoutRetries(
type = AppticsFeedback.Type.FEEDBACK,
feedbackMessage = "Feedback Message",
includeDiagnostics = true,
includeLogs = true,
forceToAnonymous = false
)
Logs
Apptics' Feedback toolkit provides the necessary APIs to add logs and diagnostic info detail from anywhere in the app. The files containing these data can be sent by the user while sending feedback.
- Use the below method to write a log.
CopiedAppticsLogs.writeLog("Some long", Log.DEBUG)
/* logtype is a predefined constant in android.Utils.Log class
* Log.VERBOSE
* Log.INFO
* Log.DEBUG
* Log.WARN
*/
- Use the below method to attach a log file.
CopiedAppticsLogs.addLogFile(file)
Note: If both addLogFile and writeLogs are set by the developer, priority is given to the addlog file. Only one logfile is allowed per feedback and it cannot exceed 1MB in size.
A diagnostic info file is a set of key-value pairs, where each pair can be grouped under the given heading. To add diagnostic info, follow the below.
CopiedAppticsLogs.addDiagnosticsInfo("HEADING", "key", "value")
Convenience APIs
Sometimes, it is necessary for your app to perform certain activities when your app opens an external app. In the feedback module, there are 2 points where an external app is opened - on clicking the attachment icon on the feedback page, and on clicking share in the screenshot to feedback prompt.
To perform this activity, override the following callback.
CopiedAppticsFeedback.onExternalAppOpened = { isOpen ->
//isOpen is true while external app is about to open
//isOpen is false while returning from an external app
}