InAppProductsModule Class
Item Index
Methods
Properties
Constants
- DOWNLOAD_STATE_ACTIVE
- DOWNLOAD_STATE_CANCELED
- DOWNLOAD_STATE_FAILED
- DOWNLOAD_STATE_FINISHED
- DOWNLOAD_STATE_PAUSED
- DOWNLOAD_STATE_WAITING
- DOWNLOAD_TIME_UNKNOWN
- PURCHASE_STATE_FAILED
- PURCHASE_STATE_PURCHASED
- PURCHASE_STATE_PURCHASING
- PURCHASE_STATE_RESTORED
- STATE_NOT_READY
- STATE_NOT_SUPPORTED
- STATE_READY
- SUPPORT_STATUS_ALL
- SUPPORT_STATUS_ERROR
- SUPPORT_STATUS_NONE
Methods
cancelDownloads
-
downloads
Cancels downloading the specificed content.
Parameters:
-
downloads
Array of DownloadsAn array Download objects.
Returns:
cancelProductRequest
()
Void
Cancels a pending getProducts call. You will not receive a receivedProducts event if you cancel a product request.
This function is only available on iOS.
Returns:
getProducts
-
params
Requests product information for the provided SKUs from iTunes Store.
The final result of this operation is reported via the receivedProducts event.
Parameters:
-
params
ObjectAn object with the following properties:
-
SKUs
Array of Strings
-
Returns:
true
if the product request was started
successfully.
getPurchases
()
Boolean
Initiates the recovery of recoverable purchases.
The final result of this operation is reported via the receivedPurchases event, which provides an array of all the purchases that have been recovered.
In addition, you will receive a
purchaseUpdate event for each purchase that is recovered, as the
recovery progresses. You will want to complete the recovered purchase
as appropriate either via the complete method, or by setting the
autoCompletePurchases property to true
.
Returns:
true
if the recovery was initiated
successfully.
getSupportStatus
()
Number
Determines whether billing is supported. Note that the return value is a number, not a simple boolean in order to accommodate the more elaborate equivalent function on Android. Use the SUPPORT_STATUS_NONE and SUPPORT_STATUS_ALL constants to interpret the returned value.
Returns:
See the SUPPORT_STATUS_* constants for possible values.
pauseDownloads
-
downloads
Pauses a set of downloads.
Parameters:
-
downloads
Array of DownloadsAn array Download objects.
Returns:
resumeDownloads
-
downloads
Resumes a set of downloads.
Parameters:
-
downloads
Array of DownloadsAn array Download objects.
Returns:
startDownloads
-
downloads
Starts downloading the specificed content. In order for a download object to be queued for downloading, it must be associated with a purchase that has not been finished yet.
Parameters:
-
downloads
Array of DownloadsAn array Download objects.
Returns:
Properties
autoCompletePurchases
Boolean
Defines whether the module will automatically mark the purchases completed.
By default this property is set to false
in order to avoid
a situation where a purchase gets "lost" due to a crash in the application.
This can happen if the module marks the purchase completed before the
application has a chance to processed the purchase and unlocked the
functionality purchased by the user.
If this property is set to true
, the module will mark every
purchase in the
PURCHASE_STATE_PURCHASED,
PURCHASE_STATE_FAILED, and
PURCHASE_STATE_RESTORED state.
If this property is set to false
, which is the default, then
it is the responsibility of the app to do the same by calling the
complete method.
Default: false
state
Number
read-only
The state of the module. On iOS, this is always going to be STATE_READY; only provided for compatibility with Android.
Constants
DOWNLOAD_STATE_WAITING
Number
One of the possible values of the state property.
Indicates that the download has not started yet.
DOWNLOAD_TIME_UNKNOWN
Number
The values of the timeRemaining property when the system cannot determine how much time is needed to finish downloading the content.
PURCHASE_STATE_PURCHASED
Number
One of the possible values of the state
property of
Purchase objects.
PURCHASE_STATE_PURCHASING
Number
One of the possible values of the state
property of
Purchase objects.
PURCHASE_STATE_RESTORED
Number
One of the possible values of the state
property of
Purchase objects.
STATE_NOT_READY
Number
One of the possible values of the state property.
This value means that module not ready to be used.
STATE_NOT_SUPPORTED
Number
One of the possible values of the state property.
This value means that the app is running in the simulator. This module provides functionality that will not work in the simulator. Please run your tests on an actual device.
STATE_READY
Number
One of the possible values of the state property.
This value means that module is ready to be used.
SUPPORT_STATUS_ALL
Number
One of the possible values returned by the getSupportStatus method.
This value means that all the product types are supported.
SUPPORT_STATUS_ERROR
Number
One of the possible values returned by the getSupportStatus method.
This value means that an error occurred while querying the support status.
SUPPORT_STATUS_NONE
Number
One of the possible values returned by the getSupportStatus method.
This value means that none of the product types are supported.
Events
downloadUpdate
This event provides updates related to startDownloads, pauseDownloads, resumeDownloads, and cancelDownloads operations.
Event Payload:
-
downloads
Array of DownloadsAn array Download objects.
purchaseUpdate
The semantics of this event are significantly different on iOS and Android. On iOS, this event is tied to the paymentQueue:updatedTransactions: native callback function.
On iOS, just like on Android, this event reports the result of a call to the purchase function.
In addition, this event is sent for each purchase that is restored as a result of a call to getPurchases function.
Furthermore, you will receive this event when your app starts up if
there are any pending purchases. A pending purchase is one that has not
been completed either by explicitly calling the
complete method or implicitly (by the module) in case the
autoCompletePurchases property is set to true
.
The app will end up with a pending purchase if it crashes before it can
record the fact that a purchase took place. Therefore it is a good idea
to attach the purchaseUpdate
event handler to the module as
soon as possible during the startup of the app and process any and all
pending purchases. This way the app's user will have access to the purchased
functionality immediately.
Event Payload:
-
purchase
Purchase
receivedProducts
This event returns the result of a getProducts call.
Event Payload:
-
products
Array of ProductsAn array of Product objects.
-
invalid
Array of StringsAn array of strings holding those product identifiers that were passed on to the getProducts function but are not valid.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorMessage
StringThe error message; only present if an error occurred.
receivedPurchases
This event returns the result of a getPurchases call.
Event Payload:
-
purchases
Array of PurchasesAn array Purchase objects. Note that this attribute is present and may contain partial information even if an error occurred.
-
errorCode
NumberThe error code; only present if an error occurred.
-
errorMessage
StringThe error message; only present if an error occurred.
stateChange
Notifies the app about a change in the state of the module. See the state property for more information.
On iOS, this event is only provided for compatibility with Android. It is only fired once, when the module is loaded, and the state is always STATE_READY.
Event Payload:
-
state
Number