Fixed showing app rate
This commit is contained in:
parent
fdfedf274f
commit
f56b158e78
1 changed files with 9 additions and 6 deletions
|
@ -33,7 +33,7 @@ object AppRater {
|
|||
private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches
|
||||
|
||||
@JvmStatic
|
||||
fun appLaunched(context: Context) {
|
||||
fun appLaunched(context: Activity) {
|
||||
val prefs = context.getSharedPreferences(APP_RATING, 0)
|
||||
if (prefs.getBoolean(DO_NOT_SHOW_AGAIN, false)) {
|
||||
return
|
||||
|
@ -56,21 +56,24 @@ object AppRater {
|
|||
if (launchCount >= LAUNCHES_UNTIL_PROMPT) {
|
||||
if (System.currentTimeMillis() >= dateFirstLaunch + DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000) {
|
||||
//showRateDialog(context, editor)
|
||||
showPlayStoreReviewDialog(context)
|
||||
showPlayStoreReviewDialog(context, editor)
|
||||
}
|
||||
}
|
||||
|
||||
editor.commit()
|
||||
}
|
||||
|
||||
private fun showPlayStoreReviewDialog(context: Context) {
|
||||
private fun showPlayStoreReviewDialog(context: Activity, editor: SharedPreferences.Editor) {
|
||||
val manager = ReviewManagerFactory.create(context)
|
||||
manager.requestReviewFlow().addOnCompleteListener { request ->
|
||||
val flow = manager.requestReviewFlow()
|
||||
flow.addOnCompleteListener { request ->
|
||||
if (request.isSuccessful) {
|
||||
val reviewInfo = request.result
|
||||
manager.launchReviewFlow(context as Activity, reviewInfo).addOnCompleteListener {
|
||||
val flowManager = manager.launchReviewFlow(context, reviewInfo)
|
||||
flowManager.addOnCompleteListener {
|
||||
if (it.isSuccessful) {
|
||||
//Toast.makeText(context, "Thanks for the feedback", Toast.LENGTH_SHORT).show()
|
||||
editor.putBoolean(DO_NOT_SHOW_AGAIN, true)
|
||||
editor.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue