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
IAPPurchaseDelegateprotocol.Declaration
Swift
static var iapPurchaseDelegate: IAPPurchaseDelegate? { get } -
The user name, if your app implements user login.
Declaration
Swift
static var applicationUsername: String? { get set } -
initialize(iapProducts:Default implementationvalidatorUrlString: iapPurchaseDelegate: applicationUsername: ) Start observing the payment queue, as soon as possible, and refresh Product list and user Receipt.
Default Implementation
Sets
DefaultPurchaseDelegateas default value foriapPurchaseDelegateandnilforapplicationUsername.Declaration
Swift
static func initialize(iapProducts: Array<IAPProduct>, validatorUrlString: String, iapPurchaseDelegate: IAPPurchaseDelegate, applicationUsername: String?)Parameters
iapProductsAn array of
IAPProduct.validatorUrlStringThe validator url retrieved from Fovea.
iapPurchaseDelegateAn instance of class that adopts the
IAPPurchaseDelegateprotocol (default value =DefaultPurchaseDelegate).applicationUsernameThe 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:IAPRefreshResultDeclaration
Swift
static func refresh(callback: @escaping IAPRefreshCallback)Parameters
callbackThe function that will be called after processing.
-
Gets all products retrieved from the App Store
See
See also:SKProductDeclaration
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:SKProductDeclaration
Swift
static func getProductBy(identifier: String) -> SKProduct?Parameters
identifierThe 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
static func canMakePayments() -> BoolReturn Value
A boolean indicates if the user is allowed.
-
purchase(productIdentifier:Default implementationquantity: callback: ) Request a Payment from the App Store.
See
See also:IAPPurchaseResultDefault Implementation
Sets
1as default value for thequantity.Declaration
Swift
static func purchase(productIdentifier: String, quantity: Int, callback: @escaping IAPPurchaseCallback)Parameters
productIdentifierThe identifier of the product to purchase.
quantityThe quantity to purchase (default value =
1).callbackThe function that will be called after processing.
-
Restore purchased products.
See
See also:IAPRefreshResultDeclaration
Swift
static func restorePurchases(callback: @escaping IAPRefreshCallback)Parameters
callbackThe function that will be called after processing.
-
Finish all transactions for the product.
Declaration
Swift
static func finishTransactions(for productIdentifier: String)Parameters
productIdentifierThe identifier of the product.
-
Checks if the last transaction state for a given product was deferred.
Declaration
Swift
static func hasDeferredTransaction(for productIdentifier: String) -> BoolParameters
productIdentifierThe 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
static func hasAlreadyPurchased() -> BoolReturn 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) -> BoolParameters
productIdentifierThe 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() -> BoolReturn 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
productIdentifierThe identifier of the product.
Return Value
The latest purchase
Dateif set ornil. -
Returns the expiry date for a subcription. May be past or future.
Declaration
Swift
static func getExpiryDate(for productIdentifier: String) -> Date?Parameters
productIdentifierThe identifier of the product.
Return Value
The expiry
Dateis set ornil.
View on GitHub
InAppPurchaseLib Protocol Reference