In-App Products Module for iOS

API Docs for: 1.0.2
Show:

InAppProductsModule Class

Module: Readme

Methods

cancelDownloads

(
  • downloads
)
Void

Available since 1.0.0

Cancels downloading the specificed content.

Parameters:

  • downloads Array of Downloads

    An array Download objects.

Returns:

Void:

cancelProductRequest

() Void

Available since 1.0.0

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:

Void:

getProducts

(
  • params
)
Boolean

Available since 1.0.0

Requests product information for the provided SKUs from iTunes Store.

The final result of this operation is reported via the receivedProducts event.

Parameters:

  • params Object

    An object with the following properties:

    • SKUs Array of Strings

Returns:

Boolean:

true if the product request was started successfully.

getPurchases

() Boolean

Available since 1.0.0

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:

Boolean:

true if the recovery was initiated successfully.

getSupportStatus

() Number

Available since 1.0.0

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:

Number:

See the SUPPORT_STATUS_* constants for possible values.

pauseDownloads

(
  • downloads
)
Void

Available since 1.0.0

Pauses a set of downloads.

Parameters:

  • downloads Array of Downloads

    An array Download objects.

Returns:

Void:

resumeDownloads

(
  • downloads
)
Void

Available since 1.0.0

Resumes a set of downloads.

Parameters:

  • downloads Array of Downloads

    An array Download objects.

Returns:

Void:

startDownloads

(
  • downloads
)
Void

Available since 1.0.0

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 Downloads

    An array Download objects.

Returns:

Void:

Properties

autoCompletePurchases

Boolean

Available since 1.0.0

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

Available since 1.0.0

The state of the module. On iOS, this is always going to be STATE_READY; only provided for compatibility with Android.

Constants

DOWNLOAD_STATE_ACTIVE

Number

Available since 1.0.0

One of the possible values of the state property of a Download object.

Indicates that the content is currently being downloaded.

DOWNLOAD_STATE_CANCELED

Number

Available since 1.0.0

One of the possible values of the state property of a Download object.

Indicates that your app canceled the download.

DOWNLOAD_STATE_FAILED

Number

Available since 1.0.0

One of the possible values of the state property of a Download object.

Indicates that an error occurred while the file was being downloaded.

DOWNLOAD_STATE_FINISHED

Number

Available since 1.0.0

One of the possible values of the state property of a Download object.

Indicates that the content was successfully downloaded.

DOWNLOAD_STATE_PAUSED

Number

Available since 1.0.0

One of the possible values of the state property of a Download object.

Indicates that your app paused the download.

DOWNLOAD_STATE_WAITING

Number

Available since 1.0.0

One of the possible values of the state property.

Indicates that the download has not started yet.

DOWNLOAD_TIME_UNKNOWN

Number

Available since 1.0.0

The values of the timeRemaining property when the system cannot determine how much time is needed to finish downloading the content.

PURCHASE_STATE_FAILED

Number

One of the possible values of the state property of Purchase objects.

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

Available since 1.0.0

One of the possible values of the state property.

This value means that module not ready to be used.

STATE_NOT_SUPPORTED

Number

Available since 1.0.1

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

Available since 1.0.0

One of the possible values of the state property.

This value means that module is ready to be used.

SUPPORT_STATUS_ALL

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that all the product types are supported.

SUPPORT_STATUS_ERROR

Number

Available since 1.0.0

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

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that none of the product types are supported.

Events

downloadUpdate

Available since 1.0.0

This event provides updates related to startDownloads, pauseDownloads, resumeDownloads, and cancelDownloads operations.

Event Payload:

  • downloads Array of Downloads

    An array Download objects.

purchaseUpdate

Available since 1.0.0

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:

receivedProducts

Available since 1.0.0

This event returns the result of a getProducts call.

Event Payload:

  • products Array of Products

    An array of Product objects.

  • invalid Array of Strings

    An array of strings holding those product identifiers that were passed on to the getProducts function but are not valid.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an error occurred.

receivedPurchases

Available since 1.0.0

This event returns the result of a getPurchases call.

Event Payload:

  • purchases Array of Purchases

    An array Purchase objects. Note that this attribute is present and may contain partial information even if an error occurred.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an error occurred.

stateChange

Available since 1.0.0

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