Last active
October 22, 2020 05:54
-
-
Save davidvavra/eb556e407907d947577cec31a8b24291 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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