Skip to main content
Question

Kotlin Making Purchases. DSK v4.6.1

  • February 27, 2022
  • 3 replies
  • 164 views

Forum|alt.badge.img+6

Hello,

My code below gets the following build errors.

  1. None of the following functions can be called with the arguments supplied.
  1. Cannot infer a type for this parameter. Please specify it explicitly.

I am copying from the Android set up guide and can’t see what I am doing wrong.  Any guidance would be greatly appreciated.

 

 

fun attemptPurchase(inActivity: Activity, forPackage: Package) {    Purchases.sharedInstance.purchasePackage(inActivity, forPackage,        onError = { error, userCancelled -> println("Error ${error.localizedMessage}")        },        onSuccess = { product, customerInfo ->        }    )}

3 replies

Forum|alt.badge.img+6
  • Author
  • Dedicated Member
  • 19 replies
  • February 28, 2022
Using purchasePackageWith works.The setup guide uses Purchases.sharedInstance.purchasePackage but the example on Github uses Purchases.sharedInstance.purchasePackageWith.

What is the difference?


joshdholtz
RevenueCat Staff
Forum|alt.badge.img+5
  • RevenueCat Staff
  • 93 replies
  • February 28, 2022

Hey @Peter Rule,

That is a great question! I did some looking into and the Kotlin guide show `purchasePackageWith` and the Java guide shows `purchasePackage`.

The `purchasePackage` version take a PurchaseListener (available for Java and Kotlin)

The `purchasePackageWith` version takes on `onError` and `onSuccess` lambda (which is only available in Kotlin).

 

KOTLIN
JAVA

 

Hopefully that helps! But happy to answer any more questions you may have!


Forum|alt.badge.img+6
  • Author
  • Dedicated Member
  • 19 replies
  • March 7, 2022

Thanks @joshdholtz but I still see the above under making purchases in the quickstart guide.

Not a problem for me now though as I’ve got it working with `purchasePackageWith` 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings