-
Notifications
You must be signed in to change notification settings - Fork 3
Update google-subscriptions-and-backwards-compatibility.md #693
base: main
Are you sure you want to change the base?
Conversation
Previewstemp/google-subscriptions-and-backwards-compatibility.md See contentsRevenueCat compatibility with Google May 2022 Subscription ChangesIn May 2022, Google introduced several new features for subscription products. These features are not supported in old versions of the RevenueCat SDK (see table below). Only products marked as “backwards compatible” in the Google Play Console are functional with RevenueCat in those older SDKs. As of purchases-android v6 (and equivalent versions of cross-platform SDKs), Google’s new subscription setup configurations are supported. We’ve automatically migrated your app to use those backwards-compatible products with all SDKs. To take full advantage of the newer Google subscription configurations and features in RevenueCat Offerings, RevenueCat now allows setting up a backwards compatible fallback product that will only be used for apps using old versions of the SDK. Product backwards compatibilityWhen creating Google Play products you can now specify whether the product is marked as backwards compatible in the Play Console. RevenueCat uses this information to know whether this product can be purchased by older version of the SDK (versions 5 and below). This information is also displayed in the product details page and will be synced from the Google play store regularly (checking the product details and status will trigger a sync immediately). App compatibility settingIn the settings page for Google Play apps, you can change whether RevenueCat Offerings should support only new versions of the RevenueCat SDK (versions 6 and above or equivalent cross-platform SDKs). You should choose the setting "Only Android SDK v6+" only if you have never used an earlier version of the RevenueCat Android SDK in production, or if you are confident that versions of your app using previous versions of the SDK do not constitute a substantial proportion of your customer base anymore. [block:image] If you select the setting "SDK v6+ and backwards compatible" and you are attaching a non-backwards compatible product to an Offering, you will additionally be able to attach a backwards compatible fallback product for use with SDK versions 5 and below and equivalent cross-platform SDKs. Please note that each version of the SDK will always only see one product per package of an offering – when a fallback product is set up, SDK v6+ will only see the regular, non-backward compatible product, and SDK v5 and below will only see the backward compatible fallback product. [block:image]
Migration of existing products to SDK v6+In order to support the new Google Play features through the RevenueCat Android SDK v6+ and above, any existing products set up in your app were automatically migrated. This step does not impact compatibility with previous versions of the SDK. Old SDK versions will continue to work as before, regardless of whether or not the migration was successful. In some cases, the migration might have failed. This could be due to invalid Play Store service credentials, a product identifier being mistyped in RevenueCat, or the product having been deleted in Google Play Console in the meantime. In these cases, a warning will be displayed in the products page and when attempting to attach such a product to an Offering: Since we are lacking required data to purchase this product in the RevenueCat Android SDK v6+, it will not work with this version of the SDK. In addition, products that couldn't be migrated prevent the creation or import of new products with the same identifier to prevent conflicts. To fix this problem, you can try one of the following:
If neither of these helps, please contact our support team. RevenueCat SDK version supportThe following table shows which SDK versions require backwards compatible products and which versions support all Google Play products:
See contentsWhat is RevenueCat?RevenueCat provides a backend and a wrapper around StoreKit and Google Play Billing to make implementing in-app purchases and subscriptions easy. With our SDK, you can build and manage your app business on any platform without having to maintain IAP infrastructure. You can read more about how RevenueCat fits into your app or you can sign up free to start building. InstallationWe provide 2 ways to install our SDK: via Unity Package Manager (UPM) in the OpenUPM registry, or as a Option 1 (recommended): Install using OpenUPM
[block:callout] [block:callout] Configure a Main Gradle TemplateGo to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window. Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle" Option 2: Import the Purchases Unity packageDownload the latest version of Purchases.unitypackage. Import the downloaded unitypackage to your Unity project. Make sure the [block:callout] Configure a Main Gradle TemplateGo to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window. Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle" Create a GameObject with the Purchases behaviorThe Purchases package will include a MonoBehavior called Purchases. This will be your access point to RevenueCat from inside Unity. It should be instantiated once and kept as a singleton. You can use properties to configure your API Key, app user ID (if you have one), and product identifiers you want to fetch. Link StoreKit (iOS only)
Subclass Purchases.Listener MonoBehaviorThe Purchases behavior takes one additional parameter, a GameObject with a Purchases.Listener component. This will be where you handle purchase events, and updated subscriber information from RevenueCat. Here is a simple example: using System;
using System.Collections.Generic;
using UnityEngine;
public class PurchasesListener : Purchases.UpdatedCustomerInfoListener
{
public override void CustomerInfoReceived(Purchases.CustomerInfo customerInfo)
{
// display new CustomerInfo
}
private void Start()
{
var purchases = GetComponent<Purchases>();
purchases.SetDebugLogsEnabled(true);
purchases.GetOfferings((offerings, error) =>
{
if (error != null)
{
// show error
}
else
{
// show offering
}
});
}
public void BeginPurchase(Purchases.Package package)
{
var purchases = GetComponent<Purchases>();
purchases.PurchasePackage(package, (productIdentifier, customerInfo, userCancelled, error) =>
{
if (!userCancelled)
{
if (error != null)
{
// show error
}
else
{
// show updated Customer Info
}
}
else
{
// user cancelled, don't show an error
}
});
}
void RestoreClicked()
{
var purchases = GetComponent<Purchases>();
purchases.RestorePurchases((customerInfo, error) =>
{
if (error != null)
{
// show error
}
else
{
// show updated Customer Info
}
});
}
} Unity EditorRunning the Purchases SDK is unsupported in the Unity Editor at this time, and may result in Proguard rulesIf you have enabled Minify in Unity, make sure to add these custom rules to your
Installation with Unity IAP side by side[block:callout] Purchases Unity 5.0.0+side by side with Unity IAP 4.8.0 This version is only compatible with version 4.8.0 and above of Unity IAP which are the ones that include BillingClient 5. To install download If using RevenueCat alongside Unity IAP 2.2.0+ or other plugin that includes the Android BillingClient library you will be getting an error when compiling that warns about some BillingClient classes being duplicated. The easiest way to remove the error would be to tell Gradle to not include the billingclient library that Unity IAP is already including. In order to do that, make sure you have Modify the dependencies {
...
// ** ADD THIS **
configurations.all {
exclude group: 'com.android.billingclient', module: 'billing'
}
} Perform a clean up of the resolved dependencies using the Also make sure to perform a resolve, so External Dependency Manager adds the right dependencies to the generated [block:callout] Troubleshooting "ClassNotFoundException" errors at Runtime in AndroidWhen exporting your project to Android, in the Build Settings window, make sure you uncheck the Installing old versions of the pluginPurchases Unity 4.2.0+side by side with Unity IAP 4.4.0 < 4.8.0 Download Purchases Unity 4.0.0 and 4.1.0side by side with Unity IAP 3.3.0 < 4.4.0 Download Next Steps
|
Motivation / Description
Changes introduced
Linear ticket (if any)
Additional comments