To enable billing-related features in the Google Play Console, you will need to publish your app build to the internal test track. Once you do that, you will be able to create in-app subscriptions.
Replace
with the latest version number available on our GitHub Tags page.{LATEST_VERSION_NUMBER}
The Apphud SDK will automatically install the Google Billing Client dependency.
After enabling Google Play Billing features for your app, you need to configure subscriptions for the paywalls.
To create a subscription:
Tip: It's not recommended to include duration words in the Product ID (e.g., avoid naming it com.app.weekly
), since the subscription duration can vary and is controlled by its base plan.
Starting in May 2022, the new subscription structure was introduced. The new model allows one subscription to have multiple plans and offers, just like Subscription Group on iOS.
The image below illustrates the new structure, where each subscription can have multiple base plans, each with several offers.
To set up a base plan, follow these steps:
You can add multiple offers to each base plan, such as free trials or discounts for certain billing cycles.
If you don't have an Apphud account yet, create your free account and add your first app. You'll need to provide the Package Name and Google Service Account Credentials.
Once your account and app are set up, it's time to configure products and paywalls.
The process for setting up subscriptions in Apphud is similar to setting up consumable in-app purchases. Simply provide the Product ID, and Apphud will handle the rest. This includes setting up the product type, pricing, terms, etc., once the first purchases with this Product ID are received.
Once the Product IDs are added to the Product Hub -> Products page, it's time to create paywalls.
Go to the Paywalls tab and create your first paywall:
The final step is to create placements and assign paywalls to them.
A placement is a specific location within a user's journey, such as onboarding, settings, or other key points, where a targeted paywall is intended to be displayed. These placements allow app developers to strategically position their paywalls in various parts of the app. Each placement can contain only one paywall per app user.
Developers can assign a specific user audience for each paywall within a placement. This means you can have different paywall configurations for various regions or user segments. Additionally, you can specify custom JSON for each paywall, providing greater flexibility in how you tailor the paywall experience to different audiences.
The main advantage of placements is the ability to optimize paywall conversion rates through strategic positioning and A/B testing. By experimenting with different paywall setups at each placement, you can continuously improve the effectiveness of your paywalls.
Initialization is simple: use the API Key found in your Apphud project settings.
To make a purchase, pass an ApphudProduct
model to the purchase method:
The Offer ID Token is optional; if not provided, the first available Offer ID Token of the given base plan will be used. You must also pass your activity instance.
The ApphudProduct
object can be retrieved from the products list of the corresponding paywall (ApphudPaywall
model). Although using placements is the recommended way to handle paywalls, you can still access the unordered paywalls list using the Apphud.paywallsDidLoadCallback { paywalls, error in }
method.
If using placements (recommended), fetch paywalls by fetching placements first:
In the callback, you will receive a list of placements that were set up in the Product Hub.
To display the products of the paywall, first find your placement by its identifier, depending on the current location in the app. For instance, if you need paywall products for onboarding, get the onboarding placement first, then get its paywall. Each placement has only one paywall per user.
Display the products on your paywall based on the product array of the paywall model. Once the user selects a plan (product), initiate a payment with the selected ApphudProduct
model.
You can view your transaction data in the Events tab in the Apphud dashboard:
That's it! You can now explore other Apphud features, like A/B Experiments or Integrations.
Apphud is the easy-to-integrate subscription app infrastructure and analytics platform for scaling your results. Sign up for Apphud today!