Created
March 23, 2024 17:52
-
-
Save SergeiMikhailovskii/dac1bbbc599ab020f4da1a3cc2c7a6c4 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
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