Show rating prompt after share sheet is dismissed
iOS: moved registerSuccessfulExport() into onDismiss so it fires after the share sheet closes, not while it is still open. Android: hold launchReview() until the activity is RESUMED so the dialog cannot overlap the share chooser. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,14 @@ import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.intPreferencesKey
|
||||
import androidx.datastore.preferences.core.longPreferencesKey
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import app.voltplan.cable.BuildConfig
|
||||
import app.voltplan.cable.analytics.Analytics
|
||||
import com.google.android.play.core.ktx.launchReview
|
||||
import com.google.android.play.core.ktx.requestReview
|
||||
import com.google.android.play.core.review.ReviewManagerFactory
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
/**
|
||||
@@ -113,6 +116,11 @@ object ReviewPrompt {
|
||||
runCatching {
|
||||
val manager = ReviewManagerFactory.create(context)
|
||||
val reviewInfo = manager.requestReview()
|
||||
// Wait until the activity is resumed so the dialog doesn't overlap a share sheet
|
||||
// that was just launched (startActivity returns immediately, so we may still be paused).
|
||||
(activity as? LifecycleOwner)?.lifecycle?.currentStateFlow
|
||||
?.filter { state: Lifecycle.State -> state.isAtLeast(Lifecycle.State.RESUMED) }
|
||||
?.first()
|
||||
manager.launchReview(activity, reviewInfo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user