Skip to content

Instantly share code, notes, and snippets.

@ivangarzab
Created March 21, 2023 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivangarzab/1ae57a915f86aafac9a8c264d80db317 to your computer and use it in GitHub Desktop.
Save ivangarzab/1ae57a915f86aafac9a8c264d80db317 to your computer and use it in GitHub Desktop.
Single function to fully trigger an In-App Review using the native Play Store library
private fun startInAppReviewFlow() {
// from Fragment class
with(ReviewManagerFactory.create(requireContext())) {
requestReviewFlow()
.addOnCompleteListener { task ->
if (task.isSuccessful) {
launchReviewFlow(requireActivity(), task.result)
.addOnCompleteListener { _ ->
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
}
} else {
Log.w(TAG, "There was a problem requesting the review flow ${task.exception}")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment