InAppPurchase
public class InAppPurchase : NSObject, InAppPurchaseLib
The main class of the library.
-
The array of
IAPProduct
.Declaration
Swift
public static var iapProducts: Array<IAPProduct>
-
The validator url retrieved from Fovea.
Declaration
Swift
public static var validatorUrlString: String?
-
The instance of class that adopts the
IAPPurchaseDelegate
protocol.Declaration
Swift
public static var iapPurchaseDelegate: IAPPurchaseDelegate?
-
The user name, if your app implements user login.
Declaration
Swift
public static var applicationUsername: String? { get set }
-
Start observing the payment queue, as soon as possible, and refresh Product list and user Receipt.
Declaration
Swift
public 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.
-
Stop observing the payment queue, when the application will terminate, for proper cleanup.
Declaration
Swift
public static func stop()
-
Refresh Product list and user Receipt.
See
See also:IAPRefreshResult
Declaration
Swift
public static func refresh(callback: @escaping IAPRefreshCallback)
Parameters
callback
The function that will be called after processing.
-
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.
-
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.
-
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 ornil
. -
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 ornil
.