AptoideBillingSDKManager
The AptoideBillingSDKManager serves as the main interface for handling in-app billing operations in Unity applications. It facilitates operations such as querying purchases, retrieving product details, consuming purchases, acknowledging non-consumable purchases, managing the user's Aptoide account sign-in, and managing billing flows. Additionally, it provides utilities for app updates and referral deeplinks.
To use the AptoideBillingSDKManager, initialize it using the InitializePlugin method, passing the required listeners, public key, and class name. The SDK ensures a seamless integration with Aptoide's billing system by managing the connection with the underlying Android bridge.
Public Methods
InitializePlugin
static void InitializePlugin(IAptoideBillingClientStateListener aptoideBillingClientStateListener, IConsumeResponseListener consumeResponseListener, IPurchasesUpdatedListener purchasesUpdatedListener, IPurchasesResponseListener purchasesResponseListener, IProductDetailsResponseListener productDetailsResponseListener, IAcknowledgeResponseListener acknowledgeResponseListener, IAptoideSignInResponseListener aptoideSignInResponseListener, IAptoideAccountStateListener aptoideAccountStateListener, string publicKey, string className)
Initializes the plugin with the required listeners and configuration.
Parameters
| Name | Type | Description |
|---|---|---|
| aptoideBillingClientStateListener | IAptoideBillingClientStateListener | Listener for billing state changes. |
| consumeResponseListener | IConsumeResponseListener | Listener for consume responses. |
| purchasesUpdatedListener | IPurchasesUpdatedListener | Listener for purchase updates. |
| purchasesResponseListener | IPurchasesResponseListener | Listener for purchase querying response. |
| productDetailsResponseListener | IProductDetailsResponseListener | Listener for Product details responses. |
| acknowledgeResponseListener | IAcknowledgeResponseListener | Listener for acknowledge responses. |
| aptoideSignInResponseListener | IAptoideSignInResponseListener | Listener for the Aptoide account sign-in result. |
| aptoideAccountStateListener | IAptoideAccountStateListener | Listener for Aptoide account sign-in state changes. |
| publicKey | String | Public key for validating purchases. |
| className | String | Class name associated with the billing SDK bridge. |
Initialize
static void Initialize(string publicKey, string className)
Initializes the Android bridge with the provided public key and class name.
StartConnection
static void StartConnection()
Starts the connection to the billing system.
EndConnection
static void EndConnection()
Ends the connection to the billing system, releasing resources.
IsReady
static bool IsReady()
Checks if the billing system is ready for operations.
Returns
Boolean value indicating the readiness of the system.
QueryProductDetailsAsync
static void QueryProductDetailsAsync(QueryProductDetailsParams queryProductDetailsParams)
Asynchronously retrieves Product details for the specified Product IDs.
Parameters
| Name | Type | Description |
|---|---|---|
| queryProductDetailsParams | QueryProductDetailsParams | Parameters for the Purchases to be queried. |
LaunchBillingFlow
static BillingResult LaunchBillingFlow(BillingFlowParams billingFlowParams)
Launches the billing flow for a specified SKU.
Parameters
| Name | Type | Description |
|---|---|---|
| billingFlowParams | BillingFlowParams | Parameters for the billing flow. |
Returns
Billing result of type BillingResult of the response received.
ConsumeAsync
static void ConsumeAsync(ConsumeParams consumeParams)
Consumes a previously purchased product.
Parameters
| Name | Type | Description |
|---|---|---|
| consumeParams | ConsumeParams | Params of the purchase to be consumed. |
AcknowledgeAsync
static void AcknowledgeAsync(AcknowledgeParams acknowledgeParams)
Acknowledges a purchase, finalizing the transaction while keeping it owned. Use this instead of ConsumeAsync for one-time non-consumable products, so the purchase is not refunded and keeps being returned by QueryPurchasesAsync. The result is delivered to the IAcknowledgeResponseListener.
This feature is remotely toggled. Verify its availability with IsFeatureSupported(4) (a response code of 0 means it is enabled).
Parameters
| Name | Type | Description |
|---|---|---|
| acknowledgeParams | AcknowledgeParams | Params of the purchase to be acknowledged. |
IsFeatureSupported
static BillingResult IsFeatureSupported(int feature)
Checks whether a specific feature is supported.
Parameters
| Name | Type | Description |
|---|---|---|
| feature | int | Value of the feature to check. |
Returns
Billing result of type BillingResult of the response received.
QueryPurchasesAsync
static void QueryPurchasesAsync(QueryPurchasesParams queryPurchasesParams)
Retrieves asynchronously the purchases associated with the user based on the specified QueryPurchasesParams to the iPurchasesResponseListener.
Parameters
| Name | Type | Description |
|---|---|---|
| queryPurchasesParams | QueryPurchasesParams | Parameters for the Purchases to be queried. |
SignInToAptoideServices
static void SignInToAptoideServices()
Launches the Aptoide account sign-in flow in a WebView. Signing in links the user's purchases to their Aptoide account, so pending and non-consumable purchases become retrievable via QueryPurchasesAsync across reinstalls and devices. The result is delivered to the IAptoideSignInResponseListener.
This feature is remotely toggled. Verify its availability with IsFeatureSupported(3) (a response code of 0 means it is enabled).
SignOutFromAptoideServices
static void SignOutFromAptoideServices()
Signs the user out of their Aptoide account, clearing the stored session and reverting all subsequent operations to the anonymous guest flow. Any registered IAptoideAccountStateListener is notified with state 0 (signed out).
IsSignedInToAptoideServices
static bool IsSignedInToAptoideServices()
Checks whether the user is currently signed in to their Aptoide account.
Returns
Boolean value indicating whether the user is signed in or not.
GetReferralDeeplink
static ReferralDeeplinkResult GetReferralDeeplink()
Retrieves a referral deeplink associated with the application.
Returns
A ReferralDeeplinkResult with the deeplink details.
IsAppUpdateAvailable
static bool IsAppUpdateAvailable()
Checks if an application update is available.
Returns
Boolean value indicating whether an update is available.
LaunchAppUpdateDialog
static void LaunchAppUpdateDialog()
Displays a dialog prompting the user to update the application.
LaunchAppUpdateStore
static void LaunchAppUpdateStore()
Launches the store page for updating the application.
Callback Handlers
The following callback methods handle responses from the Android bridge:
- BillingSetupFinishedCallback: Invoked when billing setup is complete.
- BillingServiceDisconnectedCallback: Invoked when the billing service is disconnected.
- PurchasesUpdatedCallback: Handles updates to purchases.
- PurchasesResponseCallback: Handles purchases querying results.
- ProductDetailsResponseCallback: Handles responses for Product details.
- ConsumeResponseCallback: Handles responses for consume operations.
- AcknowledgeResponseCallback: Handles responses for acknowledge operations.
- SignInResponseCallback: Handles the result of the Aptoide account sign-in.
- AccountStateChangedCallback: Handles changes to the Aptoide account sign-in state.