InAppPurchase

public class InAppPurchase : NSObject, InAppPurchaseLib

The main class of the library.

Properties

Main methods

Products information

  • Gets all products retrieved from the App Store

    See

    See also: SKProduct

    Declaration

    Swift

    public static func getProducts() -> Array<SKProduct>

    Return Value

    An array of products.

  • Gets the product by its identifier from the list of products retrieved from the App Store.

    See

    See also: SKProduct

    Declaration

    Swift

    public static func getProductBy(identifier: String) -> SKProduct?

    Parameters

    identifier

    The identifier of the product.

    Return Value

    The product if it was retrieved from the App Store.

Purchasing and Restoring

  • Checks if the user is allowed to authorize payments.

    Declaration

    Swift

    public static func canMakePayments() -> Bool

    Return Value

    A boolean indicates if the user is allowed.

  • Request a Payment from the App Store.

    See

    See also: IAPPurchaseResult

    Declaration

    Swift

    public static func purchase(productIdentifier: String, quantity: Int, callback: @escaping IAPPurchaseCallback)

    Parameters

    productIdentifier

    The identifier of the product to purchase.

    quantity

    The quantity to purchase (default value = 1).

    callback

    The function that will be called after processing.

  • Restore purchased products.

    See

    See also: IAPRefreshResult

    Declaration

    Swift

    public static func restorePurchases(callback: @escaping IAPRefreshCallback)

    Parameters

    callback

    The function that will be called after processing.

  • Finish all transactions for the product.

    Declaration

    Swift

    public static func finishTransactions(for productIdentifier: String)

    Parameters

    productIdentifier

    The identifier of the product.

  • Checks if the last transaction state for a given product was deferred.

    Declaration

    Swift

    public static func hasDeferredTransaction(for productIdentifier: String) -> Bool

    Parameters

    productIdentifier

    The identifier of the product.

    Return Value

    A boolean indicates if the last transaction state was deferred.

Purchases information

  • Checks if the user has already purchased at least one product.

    Declaration

    Swift

    public static func hasAlreadyPurchased() -> Bool

    Return Value

    A boolean indicates if the .

  • Checks if the user currently own (or is subscribed to) a given product (nonConsumable or autoRenewableSubscription).

    Declaration

    Swift

    public static func hasActivePurchase(for productIdentifier: String) -> Bool

    Parameters

    productIdentifier

    The identifier of the product.

    Return Value

    A boolean indicates if the user currently own (or is subscribed to) a given product.

  • Checks if the user has an active auto renewable subscription regardless of the product identifier.

    Declaration

    Swift

    public static func hasActiveSubscription() -> Bool

    Return Value

    A boolean indicates if the user has an active auto renewable subscription.

  • Returns the latest purchased date for a given product.

    Declaration

    Swift

    public static func getPurchaseDate(for productIdentifier: String) -> Date?

    Parameters

    productIdentifier

    The identifier of the product.

    Return Value

    The latest purchase Date if set or nil.

  • Returns the expiry date for a subcription. May be past or future.

    Declaration

    Swift

    public static func getExpiryDate(for productIdentifier: String) -> Date?

    Parameters

    productIdentifier

    The identifier of the product.

    Return Value

    The expiry Date is set or nil.