KobanKat is an unofficial RevenueCat SDK for Kotlin Multiplatform, supporting Android and iOS.
KobanKat is available on Maven Central. Add the following coordinates to your build.gradle[.kts]
or libs.versions.toml
, and then add KobanKat as a dependency to your commonMain
source set.
[versions]
kobankat = "<version>"
[libraries]
shortway-kobankat-core = { module = "io.shortway.kobankat:kobankat-core", version.ref = "kobankat" }
# Optional: adds suspending functions that return kotlin.Result to indicate success / failure.
shortway-kobankat-result = { module = "io.shortway.kobankat:kobankat-result", version.ref = "kobankat" }
# Optional: adds suspending functions that return Arrow's Either to indicate success / failure.
shortway-kobankat-either = { module = "io.shortway.kobankat:kobankat-either", version.ref = "kobankat" }
# Optional: adds extension properties representing timestamps as kotlinx-datetime Instants.
shortway-kobankat-datetime = { module = "io.shortway.kobankat:kobankat-datetime", version.ref = "kobankat" }
See Releases for the latest version.
You might also need to add this compiler flag in your build.gradle[.kts]
:
kotlin {
// ...
sourceSets {
all {
languageSettings.apply {
if (name.lowercase().startsWith("ios")) {
optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}
}
// ...
}
// ...
}
Since KobanKat depends on the official RevenueCat SDKs, we need to tell Xcode about the iOS SDK.
- Make sure you have CocoaPods installed.
cd
into youriosApp
folder (containing your.xcodeproj
and/or.xcworkspace
file(s)).- Initialize CocoaPods:
pod init
- Open the newly created
Podfile
in your favorite text editor, and add the following line:pod 'RevenueCat'
- Save the file and run:
pod install
- If you didn't have an
.xcworkspace
file before, you'll have one now. Open it in Xcode, and your app should build.
To instantiate the SDK, do the following:
- On Android only, call
PurchasesFactory.setApplication()
inApplication.onCreate()
. - In your common code, call
PurchasesFactory.configure()
.
After this, you can access the SDK's singleton instance using PurchasesFactory.sharedInstance
. This process is analogous to the official SDK.
An example implementation is provided in the composeApp
and iosApp
folders.
The versioning scheme is in the form X-Y-Z
, where:
X
is the KobanKat version.Y
is the RevenueCat Android version that is being tracked.Z
is the RevenueCat iOS version that is being tracked.
KobanKat supports Android and iOS targets for now. Most types are aliased to the respective official SDK types, so add on libraries like the official Paywalls SDK are compatible with KobanKat.
KobanKat's public API is intended to stay as close as possible to RevenueCat's official Android, iOS and hybrid SDKs. This means it should be a near drop-in replacement. The namespace has changed from com.revenuecat.purchases
to io.shortway.kobankat
. The full API reference is available at kobankat.shortway.io.
The name, KobanKat, is an homage to the original revenue cat: Meowth. 😸 This Pokémon is is attracted to round and shiny objects, can even generate revenue at will with its Pay Day move, and has a gold coin embedded in its forehead. This coin is a so-called koban coin, and that's where the name of this library comes from. ("Cat" has to be spelled with a 'K' of course. It's a Kotlin library after all.)