Skip to content

Unofficial RevenueCat wrapper library for Kotlin Multiplatform. It provides a unified API for managing subscription and in-app purchases across both iOS and Android platforms.

License

Notifications You must be signed in to change notification settings

mirzemehdi/KMPRevenueCat

Repository files navigation

KMPRevenueCat - Kotlin Multiplatform RevenueCat Library

Build Kotlin Maven Central

badge-android badge-ios

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

Installation

Minimum Requirements

  • Android: minSdkVersion 24

  • iOS: minDeploymentTarget 15.0

  • RevenueCat Android version: 7.9.0

  • RevenueCat iOS version: 4.41.1

Gradle Setup

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: Maven Central.

sourceSets {
  commonMain.dependencies {
    implementation("io.github.mirzemehdi:kmprevenuecat-purchases:<version>") //RevenueCat Purchases
    implementation("io.github.mirzemehdi:kmprevenuecat-purchases-ui:<version>") //RevenueCat Purchases UI
  }
}

Available Functions

Purchases

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()
fun syncPurchases(onResult: (Result<CustomerInfo>) -> Unit)

Purchases-UI

//This Composable can be used in Compose Multiplatform

@Composable
fun Paywall(shouldDisplayDismissButton: Boolean = true,onDismiss: () -> Unit,listener: PaywallListener?)

Contributing

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!