Skip to content

Instantly share code, notes, and snippets.

@davidvavra
Last active October 22, 2020 05:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidvavra/eb556e407907d947577cec31a8b24291 to your computer and use it in GitHub Desktop.
Save davidvavra/eb556e407907d947577cec31a8b24291 to your computer and use it in GitHub Desktop.
lateinit var manager: ReviewManager
var reviewInfo: ReviewInfo? = null
// Call this method asap, for example in onCreate()
private fun initReviews() {
manager = ReviewManagerFactory.create(this)
manager.requestReviewFlow().addOnCompleteListener { request ->
if (request.isSuccessful) {
reviewInfo = request.result
} else {
// Log error
}
}
}
// Call this when you want to show the dialog
private fun askForReview() {
if (reviewInfo != null) {
manager.launchReviewFlow(this, reviewInfo).addOnFailureListener {
// Log error and continue with the flow
}.addOnCompleteListener { _ ->
// Log success and continue with the flow
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment