InAppPurchaseLib

public protocol InAppPurchaseLib

The protocol that InAppPurchase adopts.

  • The array of IAPProduct.

    Declaration

    Swift

    static var iapProducts: Array<IAPProduct> { get }
  • The validator url retrieved from Fovea.

    Declaration

    Swift

    static var validatorUrlString: String? { get }
  • The instance of class that adopts the IAPPurchaseDelegate protocol.

    Declaration

    Swift

    static var iapPurchaseDelegate: IAPPurchaseDelegate? { get }
  • The user name, if your app implements user login.

    Declaration

    Swift

    static var applicationUsername: String? { get set }
  • Start observing the payment queue, as soon as possible, and refresh Product list and user Receipt.

    Default Implementation

    Sets DefaultPurchaseDelegate as default value for iapPurchaseDelegate and nil for applicationUsername.

    Declaration

    Swift

    static func initialize(iapProducts: Array<IAPProduct>, validatorUrlString: String, iapPurchaseDelegate: IAPPurchaseDelegate, applicationUsername: String?)

    Parameters

    iapProducts

    An array of IAPProduct.

    validatorUrlString

    The validator url retrieved from Fovea.

    iapPurchaseDelegate

    An instance of class that adopts the IAPPurchaseDelegate protocol (default value = DefaultPurchaseDelegate).

    applicationUsername

    The user name, if your app implements user login (default value = nil).

  • Stop observing the payment queue, when the application will terminate, for proper cleanup.

    Declaration

    Swift

    static func stop()
  • Refresh Product list and user Receipt.

    See

    See also:IAPRefreshResult

    Declaration

    Swift

    static func refresh(callback: @escaping IAPRefreshCallback)

    Parameters

    callback

    The function that will be called after processing.

Products information

  • Gets all products retrieved from the App Store

    See

    See also: SKProduct

    Declaration

    Swift

    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

    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

    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

    Default Implementation

    Sets 1 as default value for the quantity.

    Declaration

    Swift

    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

    static func restorePurchases(callback: @escaping IAPRefreshCallback)

    Parameters

    callback

    The function that will be called after processing.

  • Finish all transactions for the product.

    Declaration

    Swift

    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

    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

    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

    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

    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

    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

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

    Parameters

    productIdentifier

    The identifier of the product.

    Return Value

    The expiry Date is set or nil.