KMPRevenueCat is an unofficial Kotlin Multiplatform library designed as a wrapper for RevenueCat. It provides a unified API for managing subscription and in-app purchases across both iOS and Android platforms. You can see how this library is used in FindTravelNow production Compose + KMP project. For the documentation, please refer to the official RevenueCat Documentation, Kotlin section. The library is designed in the same way as it is shown in the official documentation.
Related Blog Post (if you want to integrate it yourself without this library): https://medium.com/@mirzemehdi/integrating-revenuecat-into-kotlin-multiplatform-465ffa47a97b
-
Android:
minSdkVersion 24
-
iOS:
minDeploymentTarget 15.0
-
RevenueCat Android version:
7.5.2
-
RevenueCat iOS version:
4.39.0
KMPRevenueCat is available on Maven Central. In your root project build.gradle.kts
file (or settings.gradle
file) add mavenCentral()
to repositories.
You will also need to include RevenueCat library to your ios app from XCode using Swift Package Manager or Cocoapods.
repositories {
mavenCentral()
}
Then in your shared module add desired dependencies in commonMain
. Latest version: .
sourceSets {
commonMain.dependencies {
implementation("io.github.mirzemehdi:kmprevenuecat-purchases:<version>") //RevenueCat Purchases
implementation("io.github.mirzemehdi:kmprevenuecat-purchases-ui:<version>") //RevenueCat Purchases UI
}
}
var logLevel: LogLevel
fun configure(apiKey: String, appUserId: String? = null)
fun login(appUserId: String, onResult: (Result<LogInResult>) -> Unit)
fun logOut(onResult: (Result<CustomerInfo>) -> Unit)
fun getCustomerInfo(fetchPolicy: CacheFetchPolicy = CacheFetchPolicy.default(),onResult: (Result<CustomerInfo>) -> Unit)
fun setAttributes(attributes: Map<String,String?>)
fun setFirebaseAppInstanceID(firebaseAppInstanceID: String)
fun collectDeviceIdentifiers()
fun enableAdServicesAttributionTokenCollection()
//This Composable can be used in Compose Multiplatform
@Composable
fun Paywall(shouldDisplayDismissButton: Boolean = true,onDismiss: () -> Unit,listener: PaywallListener?)
Contributions are welcome! When covering new class/functions, please, follow RevenueCat's Kotlin style, maintaining the same naming conventions for functions and classes with identical parameters. Provide clear commits and open issues for problems or suggestions on the Issues page. Your help makes this project better – thanks!