Git Product home page Git Product logo

mirzemehdi / kmprevenuecat Goto Github PK

View Code? Open in Web Editor NEW
24.0 1.0 4.0 224 KB

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.

Home Page: http://mirzemehdi.com/KMPRevenueCat/

License: Apache License 2.0

Kotlin 86.32% Swift 2.45% Ruby 11.23%
android compose-multiplatform in-app-purchase ios kotlin kotlin-multiplatform revenuecat subscriptions-and-payments

kmprevenuecat's Introduction

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!

kmprevenuecat's People

Contributors

mirzemehdi avatar qw4z1 avatar

Stargazers

Mehmet Peker avatar Jseanj avatar  avatar Serhii Hulenko avatar Stijn avatar Abhay avatar Binay Shaw avatar Diego Beraldin avatar Dmitry Kolesnikovich avatar Alexandre Pereira Nunes avatar Brahyam Meneses avatar Orelvis Lago Vasallo avatar Iván Carracedo avatar Bharath K Malviya avatar  avatar Clemodd avatar Wojciech Osak avatar  avatar  avatar Frank Blecha avatar  avatar Azat Sayan avatar Shareef Ifthekhar avatar Jordon de Hoog avatar

Watchers

 avatar

kmprevenuecat's Issues

Cannot display Paywall

I have set up RevenueCat and called the configure() which is successful.

When I try and call this (regardless of the shouldDisplayDismissButton being true or false) in my Composables screen:

Paywall(false, {}, null)

I get:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCPaywallViewController initWithOffering:displayCloseButton:dismissRequestedHandler:]: unrecognized selector sent to instance 0x10e815600'

Unable to use the library. co.touchlab:stately-common missing

Although my project compiles up just fine and I have both RevenueCat Pods installed and have set up my gradle as given in your Blog post, I get the following gradle error as soon as I add the kmprevenuecat-purchases dependency to Common:

Could not find "co.touchlab:stately-common" in [/Users/cbnewham/Desktop/KeyholderKMP/shared, /Users/cbnewham/.konan/klib, /Users/cbnewham/.konan/kotlin-native-prebuilt-macos-x86_64-1.9.23/klib/common, /Users/cbnewham/.konan/kotlin-native-prebuilt-macos-x86_64-1.9.23/klib/platform/ios_arm64]

IllegalStateException in iOS

iOS app crashes with the following exception. Looks like the library is trying to use a constructor that doesn't exist.

Also get a compiler for the error when opening the project in Android Studio

kfun:com.mmk.kmprevenuecat.purchases.ui#Paywall(kotlin.Boolean;kotlin.Function0<kotlin.Unit>;com.mmk.kmprevenuecat.purchases.ui.PaywallListener?;androidx.com
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCPaywallViewController initWithOffering:displayCloseButton:]: unrecognized selector sent to instance 0x10a03c000'

No ability to sync?

It seems that there is no ability to sync subscriptions for users who have already taken out a subscription.

I'm updating my app, originally written in Swift/StoreKit, to KMP/RevenueCat and I will not be able to release the app until I have the ability to sync with existing subscriptions.

Could you please add the necessary call to the RevenueCat function to do this?

Thanks!

Paywall dismiss button does not work

When using the Paywall composable on iOS I observe the following:

  • The shouldDisplayDismissButton works correctly
  • The onDismiss() lambda is called before/as the Paywall dialogue is displayed
  • The onDismiss button (X at top right of dialogue on iOS) does nothing (that is, the lambda is never called)

The dialogue can be dismissed by pulling down on the dialogue, which I presume is how RevenueCat have designed it in case there is no dismiss button.

Not being familiar anymore with Swift (not done it in years) and how it interacts with Kotlin I asked GPT-4 about the KMPRevenueCat Paywall implementation and it told me:
"This completion block is executed right after the presentation animation completes, not when the dialog is dismissed."

which sounds right. But I expect you will see this :-)

Version 0.3.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.