JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::InAppPurchases Class Reference

Provides in-app purchase functionality. More...

#include <juce_InAppPurchases.h>

Inheritance diagram for juce::InAppPurchases:
Collaboration diagram for juce::InAppPurchases:

Classes

struct  Download
 iOS only: represents in-app purchase download. More...
 
struct  Listener
 Represents an object that gets notified about events such as product info returned or product purchase finished. More...
 
struct  Product
 Represents a product available in the store. More...
 
struct  Purchase
 Represents a purchase of a product in the store. More...
 

Public Member Functions

void addListener (Listener *)
 Adds a listener. More...
 
void cancelDownloads (const Array< Download *> &downloads)
 iOS only: Cancels downloads of hosted content from the store. More...
 
void consumePurchase (const String &productIdentifier, const String &purchaseToken={})
 Android only: asynchronously sends a request to mark a purchase with given identifier as consumed. More...
 
void getProductsInformation (const StringArray &productIdentifiers)
 Asynchronously requests information for products with given ids. More...
 
bool isInAppPurchasesSupported () const
 Checks whether in-app purchases is supported on current platform. More...
 
void pauseDownloads (const Array< Download *> &downloads)
 iOS only: Pauses downloads of hosted content from the store. More...
 
void purchaseProduct (const String &productIdentifier, bool isSubscription, const StringArray &upgradeOrDowngradeFromSubscriptionsWithProductIdentifiers={}, bool creditForUnusedSubscription=true)
 Asynchronously requests to buy a product with given id. More...
 
void removeListener (Listener *)
 Removes a listener. More...
 
void restoreProductsBoughtList (bool includeDownloadInfo, const juce::String &subscriptionsSharedSecret={})
 Asynchronously asks about a list of products that a user has already bought. More...
 
void resumeDownloads (const Array< Download *> &downloads)
 iOS only: Resumes downloads of hosted content from the store. More...
 
void startDownloads (const Array< Download *> &downloads)
 iOS only: Starts downloads of hosted content from the store. More...
 

Static Private Member Functions

static void deleteAll ()
 Deletes all extant objects. More...
 

Private Attributes

ListenerList< Listenerlisteners
 
std::unique_ptr< Pimplpimpl
 

Friends

void juce_inAppPurchaseCompleted (void *)
 
struct Pimpl
 

Detailed Description

Provides in-app purchase functionality.

Your app should create a single instance of this class, and on iOS it should be created as soon as your app starts. This is because on application startup any previously pending transactions will be resumed.

Once an InAppPurchases object is created, call addListener() to attach listeners.

{ProductUnlocking}

Member Function Documentation

◆ addListener()

void juce::InAppPurchases::addListener ( Listener )

Adds a listener.

◆ cancelDownloads()

void juce::InAppPurchases::cancelDownloads ( const Array< Download *> &  downloads)

iOS only: Cancels downloads of hosted content from the store.

◆ consumePurchase()

void juce::InAppPurchases::consumePurchase ( const String productIdentifier,
const String purchaseToken = {} 
)

Android only: asynchronously sends a request to mark a purchase with given identifier as consumed.

To consume a product, provide product identifier as well as a purchase token that was generated when the product was purchased. The purchase token can also be retrieved by using getProductsInformation(). In general if it is available on hand, it is better to use it, because otherwise another async request will be sent to the store, to first retrieve the token.

After successful consumption, a product will no longer be returned in getProductsBought() and it will be available for purchase.

On iOS consumption happens automatically. If the product was set as consumable, this function is a no-op.

◆ deleteAll()

static void juce::DeletedAtShutdown::deleteAll ( )
staticinherited

Deletes all extant objects.

This shouldn't be used by applications, as it's called automatically in the shutdown code of the JUCEApplicationBase class.

◆ getProductsInformation()

void juce::InAppPurchases::getProductsInformation ( const StringArray productIdentifiers)

Asynchronously requests information for products with given ids.

Upon completion, for each enquired product there is going to be a corresponding Product object. If there is no information available for the given product identifier, it will be ignored.

◆ isInAppPurchasesSupported()

bool juce::InAppPurchases::isInAppPurchasesSupported ( ) const

Checks whether in-app purchases is supported on current platform.

On iOS this always returns true.

◆ pauseDownloads()

void juce::InAppPurchases::pauseDownloads ( const Array< Download *> &  downloads)

iOS only: Pauses downloads of hosted content from the store.

◆ purchaseProduct()

void juce::InAppPurchases::purchaseProduct ( const String productIdentifier,
bool  isSubscription,
const StringArray upgradeOrDowngradeFromSubscriptionsWithProductIdentifiers = {},
bool  creditForUnusedSubscription = true 
)

Asynchronously requests to buy a product with given id.

Parameters
productIdentifierThe product identifier.
isSubscription(Android only) defines if a product a user wants to buy is a subscription or a one-time purchase. On iOS, type of the product is derived implicitly.
upgradeOrDowngradeFromSubscriptionsWithProductIdentifiers(Android only) specifies subscriptions that will be replaced by the one being purchased now. Used only when buying a subscription that is an upgrade or downgrade from other ones.
creditForUnusedSubscription(Android only) controls whether a user should be credited for any unused subscription time on the products that are being upgraded or downgraded.

◆ removeListener()

void juce::InAppPurchases::removeListener ( Listener )

Removes a listener.

◆ restoreProductsBoughtList()

void juce::InAppPurchases::restoreProductsBoughtList ( bool  includeDownloadInfo,
const juce::String subscriptionsSharedSecret = {} 
)

Asynchronously asks about a list of products that a user has already bought.

Upon completion, Listener::purchasesListReceived() callback will be invoked. The user may be prompted to login first.

Parameters
includeDownloadInfo(iOS only) if true, then after restoration is successful, the downloads array passed to Listener::purchasesListReceived() callback will contain all the download objects corresponding with the purchase. In the opposite case, the downloads array will be empty.
subscriptionsSharedSecret(iOS only) required when not including download information and when there are auto-renewable subscription set up with this app. Refer to In-App-Purchase settings in the store.

◆ resumeDownloads()

void juce::InAppPurchases::resumeDownloads ( const Array< Download *> &  downloads)

iOS only: Resumes downloads of hosted content from the store.

◆ startDownloads()

void juce::InAppPurchases::startDownloads ( const Array< Download *> &  downloads)

iOS only: Starts downloads of hosted content from the store.

Friends And Related Function Documentation

◆ juce_inAppPurchaseCompleted

void juce_inAppPurchaseCompleted ( void *  )
friend

◆ Pimpl

friend struct Pimpl
friend

Member Data Documentation

◆ listeners

ListenerList<Listener> juce::InAppPurchases::listeners
private

◆ pimpl

std::unique_ptr<Pimpl> juce::InAppPurchases::pimpl
private

The documentation for this class was generated from the following file: