Android Native - 4.x to 5.x Migration
View the Android SDK Reference documentation here .
There were various updates to our API in this release, in order to best support the Amazon Store and to maintain parity with our iOS SDK, which recently migrated from ObjC to Swift.
Version Requirements
purchases-android
now requires Java 8
Type Changes
PurchaserInfo
has been deprecated and renamed toCustomerInfo
. This rename also affects to all functions that hadPurchaserInfo
in their name, likegetPurchaserInfo
which has been renamed togetCustomerInfo
.ReceiveOfferingsListener
andPurchasesErrorListener
have been renamed toReceiveOfferingsCallback
andPurchasesErrorCallback
Package.product
has been changed from being aSkuDetails
toStoreProduct
.
Old type name | New type name |
---|---|
PurchaserInfo | CustomerInfo |
ReceivePurchaserInfoListener | ReceiveCustomerInfoCallback |
UpdatedPurchaserInfoListener | UpdatedCustomerInfoListener |
ReceiveOfferingsListener | ReceiveOfferingsCallback |
PurchasesErrorListener | PurchasesErrorCallback |
Deprecated + New APIs
Configuring the SDK
The configure
function has been changed to accept a PurchasesConfiguration.Builder
. The previous function is deprecated. The new function can be used like this:
Purchases.configure(PurchasesConfiguration.Builder(this, <public_google_sdk_key>).build())
or for Amazon:
Purchases.configure(AmazonConfiguration.Builder(this, <public_amazon_sdk_key>).build())
Making purchases
purchasePackage
and purchaseProduct
callbacks have been changed to return a StoreTransaction
instead of a Purchase
in the onCompleted
.
This means that MakePurchaseListener
has been deprecated in favor of PurchaseCallback
. There is a helper extension function MakePurchaseListener.toPurchaseCallback()
that can help migrate. For purchasing functions that accept an UpgradeInfo
, ProductChangeListener
has been deprecated in favor of ProductChangeCallback
.
Similarly, you can use ProductChangeListener.toProductChangeCallback()
and MakePurchaseListener.toProductChangeCallback()
in Kotlin for an easy migration. Due to the same change, Kotlin helper purchaseProductWith
now accepts a StoreProduct
instead of aSkuDetails
Getting products
getSubscriptionSkus
and getNonSubscriptionSkus
callbacks has been changed to return StoreProduct
objects instead of SkuDetails
.
This means that GetSkusResponseListener
has been deprecated in favor of GetStoreProductsCallback
. You can use GetSkusResponseListener.toGetStoreProductsCallback()
in Kotlin for an easy migration.
For the same reasons, getSubscriptionSkusWith
and getNonSubscriptionSkusWith
now receive storeProducts
instead of skus
.
Deprecated APIs
Deprecated | New |
---|---|
configure(Context, String, String?, Boolean, ExecutorService) | configure(PurchasesConfiguration) |
invalidatePurchaserInfoCache() | invalidateCustomerInfoCache() |
removeUpdatedPurchaserInfoListener() | removeUpdatedCustomerInfoListener() |
getPurchaserInfo(ReceivePurchaserInfoListener) | getCustomerInfo(ReceiveCustomerInfoCallback) |
restorePurchases(ReceivePurchaserInfoListener) | restorePurchases(ReceiveCustomerInfoCallback) |
logOut(ReceivePurchaserInfoListener) | logOut(ReceiveCustomerInfoCallback) |
purchaseProduct(Activity, SkuDetails, MakePurchaseListener) | purchaseProduct(Activity, StoreProduct, PurchaseCallback) |
purchaseProduct(Activity, SkuDetails, UpgradeInfo, ProductChangeListener) | purchaseProduct(Activity, StoreProduct, UpgradeInfo, ProductChangeCallback) |
purchasePackage(Activity, Package, MakePurchaseListener) | purchasePackage(Activity, Package, PurchaseCallback) |
purchasePackage(Activity, Package, UpgradeInfo, ProductChangeListener) | purchasePackage(Activity, Package, UpgradeInfo, ProductChangeCallback) |
getSubscriptionSkus(List<String>, GetSkusResponseListener) | getSubscriptionSkus(List<String>, GetStoreProductsCallback) |
getNonSubscriptionSkus(List<String>, GetSkusResponseListener) | getNonSubscriptionSkus(List<String>, GetStoreProductsCallback) |
Kotlin Helpers Changes
Old signature | New signature |
---|---|
getPurchaserInfoWith((PurchasesError) -> Unit, (PurchaserInfo) -> Unit) | getCustomerInfoWith((PurchasesError) -> Unit, (CustomerInfo) -> Unit) |
purchasePackageWith(Activity, Package, (PurchasesError) -> Unit, (Purchase, PurchaserInfo) -> Unit) | purchasePackage(Activity, Package, (PurchasesError) -> Unit, (StoreTransaction, CustomerInfo) -> Unit) |
purchasePackageWith(Activity, Package, UpgradeInfo, (PurchasesError) -> Unit, (Purchase, PurchaserInfo) -> Unit) | purchasePackage(Activity, Package, UpgradeInfo, (PurchasesError) -> Unit, (StoreTransaction, CustomerInfo) -> Unit) |
purchaseProductWith(Activity, SkuDetails, (PurchasesError) -> Unit, (Purchase, PurchaserInfo) -> Unit) | purchaseProductWith(Activity, StoreProduct, (PurchasesError) -> Unit, (StoreTransaction, CustomerInfo) -> Unit) |
purchaseProductWith(Activity, SkuDetails, UpgradeInfo, (PurchasesError) -> Unit, (Purchase, PurchaserInfo) -> Unit) | purchaseProductWith(Activity, StoreProduct, UpgradeInfo, (PurchasesError) -> Unit, (StoreTransaction, CustomerInfo) -> Unit) |
Removed APIs
Some deprecated functions have been removed: identify
, reset
, createAlias
, isBillingSupported
, isFeatureSupported
, addAttributionData
and the versions of purchaseProduct
/purchasePackage
accepting UpgradeInfo
and MakePurchaseListener
For more information about recommended identity logic following the removal of these identification methods, see Identifying Users.
Removed APIs |
---|
purchaseProduct(Activity, SkuDetails, UpgradeInfo, MakePurchaseListener) |
purchasePackage(Activity, Package, UpgradeInfo, MakePurchaseListener) |
createAlias(String, ReceivePurchaserInfoListener?) |
identify(String, ReceivePurchaserInfoListener?) |
reset(ReceivePurchaserInfoListener?) |
createAliasWith(String, (PurchasesError) -> Unit, (PurchaserInfo) -> Unit) |
identifyWith(String, (PurchasesError) -> Unit, (PurchaserInfo) -> Unit) |
resetWith((PurchasesError) -> Unit, (PurchaserInfo) -> Unit) |
isBillingSupported(Context, Callback<Boolean>) |
isFeatureSupported(BillingClient.FeatureType, Context, Callback<Boolean>) |
addAttributionData(JSONObject, AttributionNetwork, String?) |
addAttributionData(Map<String, Any?>, AttributionNetwork, String?) |
AttributionNetwork |
Other changes
- Amazon support (see the section in our docs for more information)
Reporting undocumented issues
Feel free to file an issue! New RevenueCat Issue.
Updated 7 days ago