Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Added templates that support multiple packages #684

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelAtRC
Copy link
Contributor

This is just to let users know which templates they might want to consider using right off the bat if they plan to use multiple packages.

Motivation / Description

I have had this question come up in tickets and community posts so I figured that we should add it to the docs so the users know which templates allow for multiple packages.

Changes introduced

Added list of current templates that support this

I have had this question come up in tickets and community posts so I figured that we should add it to the docs so the users know which templates allow for multiple packages.
@RCGitBot
Copy link
Contributor

RCGitBot commented Feb 2, 2024

Previews

temp/creating-paywalls.md

See contents

[block:embed]
{
"html": "<iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPNiVCdExtkw%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPNiVCdExtkw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPNiVCdExtkw%2Fhqdefault.jpg&key=7788cb384c9f4d5dbbdbeffd9fe4b92f&type=text%2Fhtml&schema=youtube" width="854" height="480" scrolling="no" title="YouTube embed" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"></iframe>",
"url": "https://www.youtube.com/watch?v=PNiVCdExtkw",
"title": "How to use RevenueCat Paywalls",
"favicon": "https://www.google.com/favicon.ico",
"image": "https://i.ytimg.com/vi/PNiVCdExtkw/hqdefault.jpg",
"provider": "https://www.youtube.com/",
"href": "https://www.youtube.com/watch?v=PNiVCdExtkw",
"typeOfEmbed": "youtube"
}
[/block]

How to create a new Paywall

Select an Offering

First, click on Paywalls in the Products and pricing section of the Project you’re working on.

Products and pricing

Then, click + Add paywall next to the Offering that you want to create a Paywall for.

Add paywall

📘

If you’re looking to experiment with a new paywall, consider duplicating your default Offering and attaching your new paywall to the duplicated Offering.

Select a template

The first thing to do when creating a new Paywall is to select the template you’ll use as the starting point. Templates may support different package setups, content layouts, image sizes, and much more; so we recommend browsing each template to pick the one that’s best suited for what you’re looking to accomplish with your paywall.

For example, if you’re trying to draw contrast between a few different packages you’re offering, try the #2 - Sphynx template. Or, if you want to try your own version of the Blinkist Free Trial Paywall start with the #3 - Leopard template.

If you need to showcase multiple packages, consider using the following templates:

  • Template 2 - Sphynx Content
  • Template 4 - Persian Content
  • Template 5 - Bengal Content

How to configure your Paywall

Once you’ve selected a template, you can configure any of its properties on the right side of the screen and see the change previewed immediately.

Packages

Packages represent the individual products you want to serve a customer on your Paywall. You don’t necessarily need to display every package that’s available in your Offering, and some templates may only support displaying one or a limited number of packages, so be sure to choose a template that reflects the options you want to offer your customers.

For templates that support multiple packages, you should select packages in the order that you’d like them to display. Then, you can separately choose which package should be preselected for your customers by default.

📘

To test the impact of that choice, you can duplicate your Offering, preselect a different package, and run an Experiment between the two Offerings to see how it influences customer behavior on your Paywall.

Strings

How you describe your product has a huge impact on how likely a customer is to subscribe to it. Every descriptive string on our Paywall templates is fully configurable so you have control over exactly how you pitch your product.

📘

Try using markdown formatting in any string property to add custom styling to your Paywall.

Variables

For some Paywall strings you may want to set values based on the package that’s being displayed instead of hardcoding a single value, such as when quoting a price, or describing the duration of an Introductory Offer.

To make this easier and ensure accuracy, we recommend using Variables for these values that are package-specific.

For example, to show a CTA like “Try 7 Days Free & Subscribe”, you should instead use the {{ sub_offer_duration }} variable, and enter “Try {{ sub_offer_duration }} Free & Subscribe” to ensure the string is accurate for any product you use, even if you make changes to the nature of the offer in the future.

We support the following variables:

Variable Description Example Value
product_name The name of the product from the store (e.g. product localized title from StoreKit) for a given package CatGPT
price The localized price of a given package $39.99
price_per_period The localized price of a given package with its period length if applicable $39.99/yr
total_price_and_per_month The localized price of a given package with its monthly equivalent price if it has one $39.99/yr ($3.33/mo)
sub_price_per_month The localized price of a given package converted to a monthly equivalent price $3.33
sub_duration The duration of the subscription; '1 month', '3 months', '1 year', etc. 1 year
sub_duration_in_months The duration of the subscription in months; '3 months', '12 months', etc. 12 months
sub_period The length of each period of the standard offer on a given package Monthly
sub_offer_duration The period of the introductory offer on a given package 7 days
sub_offer_duration_2 The period of the second introductory offer on a given package (Google Play only) 7 days
sub_offer_price The localized price of the introductory offer of a given package $4.99
sub_offer_price_2 The localized price of the second introductory offer of a given package (Google Play only) $4.99

Previewing Paywalls

Click the Show preview values checkbox to see your Paywall with example preview values instead of the raw variables.

The paywall preview is generated using our example data. Please note that you may observe placeholder values from the example values in the table above, such as product names or prices in the preview of your newly created paywall. To obtain a more accurate preview, we recommend running your application on your physical device or in the simulator, as this will present details more closely aligned with your actual product information.

Intro offer eligibility

RevenueCat Paywalls automatically check for Introductory Offer eligibility, and therefore for applicable fields like the Call to action and Offer details you can enter distinct strings based on the nature of the offer. For example, you may want to highlight the length of your free trial for a customer who is eligible for that Introductory Offer.

Uploading images

Use the Select a file button for the applicable image to upload your own to use for your Paywall. We’ll center and scale the image to fit, regardless of its aspect ratio, so we recommend using source images that are appropriate for the area of the template they cover. We support .jpg, jpeg, and .png files up to 5MB.

Colors

Use your own hex codes, select a custom color, or use our color picker to select background and text colors for each element that reflect your app’s branding.

📘

The color picker can be used outside of your browser window as well if you need to grab colors from assets in other applications.

Localization

RevenueCat Paywalls come with built-in support for localization. This will allow you to customize your paywall content for all the languages that your app supports.

Locales can be added to your paywall through the 'Localization' dropdown.

[block:image]
{
"images": [
{
"image": [
"https://files.readme.io/c53fb56-Screenshot_2023-08-31_at_3.51.13_PM.png",
"",
""
],
"align": "center"
}
]
}
[/block]

Each paywall template may differ in the localized values that you will need to provide. The options that most templates have are:

  • Title
  • Subtitle
  • Package details
  • Package details for an introductory offer
  • Call to action
  • Call to action for an introductory offer

Since RevenueCatUI allows for dynamic text with Variables, all the output of variables will automatically localized. This includes period lengths like "Annual", "Monthly" and "Weekly" being localized to "Anual", "Mensual", and "Semanalmente". Price per period like "$6.99/mo" and "$53.99/yr" will also be localized to "$6.99/m." and "$53.99/año".

Other paywall components like "Restore purchases", "Terms of Service", and "Privacy Policy" will also automatically be localized.

Supported locales

We currently support all 39 locales that are supported on App Store Connect.

  • Arabic (Saudi Arabia) - ar
  • Catalan - ca
  • Chinese (Simplified) - zh
  • Chinese (Traditional) - zh
  • Croatian - hr
  • Czech - cs
  • Danish - da
  • Dutch (Netherlands) - nl
  • English (Australia) - en
  • English (Canada) - en
  • English (United Kingdom) - en
  • English (United States) - en
  • Finnish - fi
  • French (Canada) - fr
  • French (France) - fr
  • German (Germany) - de
  • Greek - el
  • Hebrew - he
  • Hindi - hi
  • Hungarian - hu
  • Indonesian - id
  • Italian - it
  • Japanese - ja
  • Korean - ko
  • Malay - ms
  • Norwegian - no
  • Polish - pl
  • Portuguese (Brazil) - pt
  • Portuguese (Portugal) - pt
  • Romanian - ro
  • Russian - ru
  • Slovak - sk
  • Spanish (Mexico) - es
  • Spanish (Spain) - es
  • Swedish - sv
  • Thai - th
  • Turkish - tr
  • Ukrainian - uk
  • Vietnamese - vi

temp/unity.md

See contents

What 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.

Installation

We provide 2 ways to install our SDK: via Unity Package Manager (UPM) in the OpenUPM registry, or as a .unitypackage.

Option 1 (recommended): Install using OpenUPM

  1. First you need to import the EDM4U plugin into your project if you haven't already. This plugin will add all the Android and iOS dependencies automatically when building your project. To do this, you can:
    • Download the external-dependency-manager-latest.unitypackage file from the root of the EDM4U repo.
    • Import the downloaded unitypackage to your project.
  2. Then, you can add the OpenUPM scoped registry. To do this, go to your project's settings -> Package Manager, and add a new scoped registry with URL https://package.openupm.com and scopes: com.openupm and com.revenuecat.purchases-unity. It should look like this:
  3. Then, go to the Package Manager and from "My Registries", select the RevenueCat package and click on Install.

[block:callout]
{
"type": "info",
"title": "Using OpenUPM-CLI",
"body": "If you prefer, you can also use OpenUPM-CLI to add the scoped registry and the package through the command line. To do that, install the OpenUPM-CLI if you haven't already, then run openupm add com.revenuecat.purchases-unity. That should be it!"
}
[/block]

[block:callout]
{
"type": "warning",
"title": "If using UnityIAP alongside RevenueCat",
"body": "If you're using UnityIAP, you need to follow special instructions outlined below."
}
[/block]

Configure a Main Gradle Template

Go to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window.

Screenshot 2024-02-02 at 12 52 35 PM

Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle"

Screenshot 2024-02-01 at 12 13 50 PM Screenshot 2024-02-02 at 12 52 35 PM

Option 2: Import the Purchases Unity package

Download the latest version of Purchases.unitypackage.

Import the downloaded unitypackage to your Unity project. Make sure the PlayServiceResolver and the ExternalDependencyManager folders are also added. These folders will install the EDM4U plugin, which will add all the Android and iOS dependencies automatically when building your project.
If you're running purchases-unity v3.5.1 or later, also make sure that the RevenueCatPostInstall script is added, since it will set up StoreKit for iOS and prevent issues when uploading builds to App Store Connect in Unity 2020.

[block:callout]
{
"type": "warning",
"title": "ExternalDependencyManager plugin",
"body": "Make sure the ExternalDependencyManager is properly installed. Otherwise our plugin will not be able to compile. If you don't see the option under the Assets menu after restarting the editor, try reinstalling the RevenueCat plugin or manually importing the EDM4U plugin."
}
[/block]

Configure a Main Gradle Template

Go to Project -> Build Settings -> Player Settings -> Android tab -> Publishing Settings, and check "Custom Base Gradle Template", then close that window.

Screenshot 2024-02-02 at 12 52 35 PM

Go to Assets -> External Dependency Manager -> Android Resolver -> Settings, then check "Patch mainTemplate.gradle"

Screenshot 2024-02-01 at 12 13 50 PM Screenshot 2024-02-02 at 12 52 35 PM

Create a GameObject with the Purchases behavior

The 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)

StoreKit should automatically be linked. If you run into any issues, add StoreKit.framework to Linked Frameworks and Libraries in Xcode.

Subclass Purchases.Listener MonoBehavior

The 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 Editor

Running the Purchases SDK is unsupported in the Unity Editor at this time, and may result in NullReferenceException: Object reference not set to an instance of an object errors. Please build and run your app instead.

Proguard rules

If you have enabled Minify in Unity, make sure to add these custom rules to your Assets/Plugins/Android/proguard-user.txt and enable the Custom Proguard File setting in Publishing Settings:

-keep class com.revenuecat.** { *; }

Installation with Unity IAP side by side

[block:callout]
{
"type": "danger",
"body": "Make sure to use version 5.3.0 of our plugin. Due to incompatibilities with the version of BillingClient used by Unity IAP, the latest versions of the plugin won't work alongside Unity IAP until Unity IAP gets updated to BillingClient 6.x.x.",
"title": "Unity IAP doesn't work with version 6 of the purchases plugin"
}
[/block]

Purchases Unity 5.0.0+

RevenueCat's Purchases Unity SDK 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 Purchases.unityPackage and install as normal. Then follow the instructions indicated in the "Troubleshooting "duplicated class" errors"

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 Custom Main Gradle Template selected in the Android Player Settings... That should create a mainTemplate.gradle inside the Assets/Plugins/Android.

Modify the mainTemplate.gradle to include the following at the end of the dependencies block:

dependencies {
    ...
    
    // ** ADD THIS **
    configurations.all {
        exclude group: 'com.android.billingclient', module: 'billing'
    }
}

Perform a clean up of the resolved dependencies using the Assets/External Dependency Manager/Android Resolver/Delete Resolved Libraries menu. This will cleanup the previously downloaded .aars in Assets/Plugins/Android. Otherwise you could end up with duplicated classes errors.

Also make sure to perform a resolve, so External Dependency Manager adds the right dependencies to the generated build.gradle.

[block:callout]
{
"type": "danger",
"body": "The above instructions instructions will also apply if using other plugin that includes the Android InAppBillingService class, or for some other reason you get an error regarding duplicated classes."
}
[/block]

Troubleshooting "ClassNotFoundException" errors at Runtime in Android

When exporting your project to Android, in the Build Settings window, make sure you uncheck the Symlink Sources checkbox. That will make it so Unity actually uses the correct source files for our SDK.

Installing old versions of the plugin

Purchases Unity 4.2.0+

RevenueCat's Purchases Unity SDK 4.2.0+

side by side with Unity IAP 4.4.0 < 4.8.0

Download Purchases-UnityIAP.unityPackage and install as normal. Skip the rest of the instructions in this page.

Purchases Unity 4.0.0 and 4.1.0

RevenueCat's Purchases Unity SDK 4.1.0+

side by side with Unity IAP 3.3.0 < 4.4.0

Download Purchases-UnityIAP.unityPackage and install as normal. Skip the rest of the instructions in this page.

Next Steps

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants