Class CodelessIAPStoreListener
Initializes Unity IAP with the Product
s defined in the default IAP ProductCatalog.
Automatically initializes at runtime load when enabled in the GUI. enableCodelessAutoInitialization
Manages IAPButton
s and IAPListener
s.
Inherited Members
Namespace: UnityEngine.Purchasing
Syntax
public class CodelessIAPStoreListener : IDetailedStoreListener, IStoreListener
Fields
catalog
For adding ProductDefinition
this default ProductCatalog
is
loaded from the Project
when I am instantiated.
Declaration
protected ProductCatalog catalog
Field Value
Type | Description |
---|---|
ProductCatalog |
controller
For advanced scripted IAP actions, use this session's IStoreController
after initialization.
Declaration
protected IStoreController controller
Field Value
Type | Description |
---|---|
IStoreController |
extensions
For advanced scripted store-specific IAP actions, use this session's IExtensionProvider
after initialization.
Declaration
protected IExtensionProvider extensions
Field Value
Type | Description |
---|---|
IExtensionProvider |
initializationComplete
Allows outside sources to know whether the successful initialization has completed.
Declaration
public static bool initializationComplete
Field Value
Type | Description |
---|---|
Boolean |
Properties
Instance
Singleton of me. Initialized on first access.
Also initialized by RuntimeInitializeOnLoadMethod if ProductCatalog.enableCodelessAutoInitialization.enableCodelessAutoInitialization
is true.
Declaration
public static CodelessIAPStoreListener Instance { get; }
Property Value
Type | Description |
---|---|
CodelessIAPStoreListener |
StoreController
For advanced scripted IAP actions, use this session's IStoreController
after
initialization.
Declaration
public IStoreController StoreController { get; }
Property Value
Type | Description |
---|---|
IStoreController |
Methods
AddButton(CodelessIAPButton)
Register an CodelessIAPButton
to send IAP initialization and purchasing events.
Use to making IAP functionality visible to the user.
Declaration
public void AddButton(CodelessIAPButton button)
Parameters
Type | Name | Description |
---|---|---|
CodelessIAPButton | button |
AddButton(IAPButton)
Register an IAPButton
to send IAP initialization and purchasing events.
Use to making IAP functionality visible to the user.
Declaration
[Obsolete("CodelessIAPStoreListener.AddButton(IAPButton button) is deprecated, please use CodelessIAPStoreListener.AddButton(CodelessIAPButton button) instead.", false)]
public void AddButton(IAPButton button)
Parameters
Type | Name | Description |
---|---|---|
IAPButton | button | The |
AddListener(IAPListener)
Register an IAPListener
to send IAP purchasing events.
Declaration
public void AddListener(IAPListener listener)
Parameters
Type | Name | Description |
---|---|---|
IAPListener | listener | Listener to receive IAP purchasing events |
GetProduct(String)
Access a Product
for this app.
Declaration
public Product GetProduct(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | A product identifier to find as a |
Returns
Type | Description |
---|---|
Product | A |
GetStoreConfiguration<T>()
For advanced scripted store-specific IAP actions, use this session's IStoreConfiguration
s.
Note, these instances are only available after initialization through Codeless IAP, currently.
Declaration
public T GetStoreConfiguration<T>()
where T : IStoreConfiguration
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | A subclass of |
GetStoreExtensions<T>()
For advanced scripted store-specific IAP actions, use this session's IStoreExtension
s after initialization.
Declaration
public T GetStoreExtensions<T>()
where T : IStoreExtension
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | A subclass of |
HasProductInCatalog(String)
Inspect my ProductCatalog
for a product identifier.
Declaration
public bool HasProductInCatalog(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | Product identifier to look for in catalog. Note this is not the store-specific identifier. |
Returns
Type | Description |
---|---|
Boolean | Whether this identifier exists in catalog |
InitiatePurchase(String)
Purchase a product by its identifier.
Sends purchase failure event with PurchaseFailureReason.PurchasingUnavailable.PurchasingUnavailable
to all registered IAPButtons if not yet successfully initialized.
Declaration
public void InitiatePurchase(string productID)
Parameters
Type | Name | Description |
---|---|---|
String | productID | Product identifier of |
OnInitialized(IStoreController, IExtensionProvider)
Implementation of UnityEngine.Purchasing.IStoreListener.OnInitialized.Purchasing.IStoreListener.OnInitialized
which captures
successful IAP initialization results and refreshes all registered IAPButton
s.
Declaration
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
Parameters
Type | Name | Description |
---|---|---|
IStoreController | controller | Set as the current IAP session's single |
IExtensionProvider | extensions | Set as the current IAP session's single |
Implements
OnInitializeFailed(InitializationFailureReason)
Implementation of UnityEngine.Purchasing.IStoreListener.OnInitializeFailed.Purchasing.IStoreListener.OnInitializeFailed
which
logs the failure reason.
Declaration
[Obsolete("OnInitializeFailed(InitializationFailureReason error) is deprecated, please use OnInitializeFailed(InitializationFailureReason error, string message) instead.")]
public void OnInitializeFailed(InitializationFailureReason error)
Parameters
Type | Name | Description |
---|---|---|
InitializationFailureReason | error | Reported in the app log. |
Implements
OnInitializeFailed(InitializationFailureReason, String)
Implementation of UnityEngine.Purchasing.IStoreListener.OnInitializeFailed.Purchasing.IStoreListener.OnInitializeFailed
which
logs the failure reason.
Declaration
public void OnInitializeFailed(InitializationFailureReason error, string message)
Parameters
Type | Name | Description |
---|---|---|
InitializationFailureReason | error | Reported in the app log. |
String | message | More information on the failure reason. |
Implements
OnPurchaseFailed(Product, PurchaseFailureDescription)
Implementation of UnityEngine.Purchasing.IDetailedStoreListener.OnPurchaseFailed.Purchasing.IDetailedStoreListener.OnPurchaseFailed
indicating
a purchase failed with a detailed failure description. Send this event to any appropriate registered
IAPButton
s and IAPListener
s.
Logs an error if there are no appropriate registered handlers.
Declaration
public void OnPurchaseFailed(Product product, PurchaseFailureDescription description)
Parameters
Type | Name | Description |
---|---|---|
Product | product | What failed to purchase |
PurchaseFailureDescription | description | Why the purchase failed |
Implements
OnPurchaseFailed(Product, PurchaseFailureReason)
Implementation of UnityEngine.Purchasing.IStoreListener.OnPurchaseFailed.Purchasing.IStoreListener.OnPurchaseFailed
indicating
a purchase failed with specified reason. Send this event to any appropriate registered
IAPButton
s and IAPListener
s.
Logs an error if there are no appropriate registered handlers.
Declaration
public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
Parameters
Type | Name | Description |
---|---|---|
Product | product | What failed to purchase |
PurchaseFailureReason | reason | Why the purchase failed |
Implements
ProcessPurchase(PurchaseEventArgs)
Implementation of UnityEngine.Purchasing.IStoreListener.ProcessPurchase.Purchasing.IStoreListener.ProcessPurchase
which forwards
this successful purchase event to any appropriate registered IAPButton
s and
IAPListener
s. Logs an error if there are no appropriate registered handlers.
Declaration
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PurchaseEventArgs | e | Data for this purchase |
Returns
Type | Description |
---|---|
PurchaseProcessingResult | Any indication of whether this purchase has been completed by any of my appropriate registered
|
Implements
RemoveButton(CodelessIAPButton)
Stop sending initialization and purchasing events to an CodelessIAPButton
. Use when disabling
the button, e.g. when closing a scene containing that button and wanting to prevent the user from making any
IAP events for its product.
Declaration
public void RemoveButton(CodelessIAPButton button)
Parameters
Type | Name | Description |
---|---|---|
CodelessIAPButton | button |
RemoveButton(IAPButton)
Stop sending initialization and purchasing events to an IAPButton
. Use when disabling
the button, e.g. when closing a scene containing that button and wanting to prevent the user from making any
IAP events for its product.
Declaration
[Obsolete("CodelessIAPStoreListener.RemoveButton(IAPButton button) is deprecated, please use CodelessIAPStoreListener.RemoveButton(CodelessIAPButton button) instead.", false)]
public void RemoveButton(IAPButton button)
Parameters
Type | Name | Description |
---|---|---|
IAPButton | button |
RemoveListener(IAPListener)
Unregister an IAPListener
from IAP purchasing events.
Declaration
public void RemoveListener(IAPListener listener)
Parameters
Type | Name | Description |
---|---|---|
IAPListener | listener | Listener to no longer receive IAP purchasing events |