Skip to content

Instantly share code, notes, and snippets.

@SergeiMikhailovskii
Created March 23, 2024 17:52
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 SergeiMikhailovskii/dac1bbbc599ab020f4da1a3cc2c7a6c4 to your computer and use it in GitHub Desktop.
Save SergeiMikhailovskii/dac1bbbc599ab020f4da1a3cc2c7a6c4 to your computer and use it in GitHub Desktop.
class RuStoreInAppReviewInitParams(val context: Context)
class RuStoreInAppReviewManager(private val params: RuStoreInAppReviewInitParams) : InAppReviewDelegate {
override fun requestInAppReview() = flow {
val activity = params.context
val manager = RuStoreReviewManagerFactory.create(activity)
val reviewInfo = manager.requestReviewFlow().await()
manager.launchReviewFlow(reviewInfo).await()
emit(ReviewCode.NO_ERROR)
}.catch { e ->
if (e is RuStoreException) {
val exceptionMapper = RuStoreExceptionMapper()
emit(exceptionMapper(e))
} else {
throw e
}
}
override fun requestInMarketReview() = flow {
val context = params.context
val packageName = context.packageName
context.openMarket(
deeplink = "rustore://apps.rustore.ru/app/$packageName",
url = "https://apps.rustore.ru/app/$packageName"
)
emit(ReviewCode.NO_ERROR)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment