API documentation
Classes and Protocols
The most important class is InAppPurchase
. All the functions you need are defined in this class.
If you have consumable and/or non-renewing subscription products in your application, you must have a class that adopts the IAPPurchaseDelegate
protocol.
Products
Input: the library requires an array of
IAPProduct
when it is initialized.Output: the library will returns SKProduct extended with helpful methods. See the
SKProduct
extension.
Callbacks
refresh()
, purchase()
and restorePurchases()
are asynchronous functions. You must provide a callback that will allow you to perform actions depending on the result.
For
refresh()
andrestorePurchases()
functions, the result will beIAPRefreshResult
.For
purchase()
function, the result will beIAPPurchaseResult
.
Errors
When calling refresh()
, purchase()
or restorePurchases()
, the callback can return an IAPError
if the state is failed
. Look at IAPErrorCode
to see the list of error codes you can receive.
-
The main class of the library.
See moreDeclaration
Swift
public class InAppPurchase : NSObject, InAppPurchaseLib
-
The protocol that
See moreInAppPurchase
adopts.Declaration
Swift
public protocol InAppPurchaseLib
-
The default implementation of
See moreIAPPurchaseDelegate
if no other is provided. It is enough if you only have non-consumable and/or auto-renewable subscription products.Declaration
Swift
public class DefaultPurchaseDelegate : IAPPurchaseDelegate
-
The protocol that you must adopt if you have consumable and/or non-renewing subscription products.
See moreDeclaration
Swift
public protocol IAPPurchaseDelegate
-
Basic product information used by
See moreInAppPurchase
.Declaration
Swift
public struct IAPProduct
-
Types of in-app purchases.
See moreDeclaration
Swift
public enum IAPProductType
-
Declaration
Swift
extension SKProduct
-
The format used for the localized subscription periods.
See moreDeclaration
Swift
public enum IAPPeriodFormat
-
Undocumented
Declaration
Swift
public typealias IAPPurchaseCallback = (IAPPurchaseResult) -> Void
-
Undocumented
Declaration
Swift
public typealias IAPRefreshCallback = (IAPRefreshResult) -> Void
-
The result returned in the
See morepurchase()
callback.Declaration
Swift
public struct IAPPurchaseResult
-
The result returned in the
See morerefresh()
orrestorePurchases()
callback.Declaration
Swift
public struct IAPRefreshResult
-
The list of the different states of the
See moreIAPPurchaseResult
.Declaration
Swift
public enum IAPPurchaseResultState
-
The list of the different states of the
See moreIAPRefreshResult
.Declaration
Swift
public enum IAPRefreshResultState
-
When calling
See morerefresh()
,purchase()
orrestorePurchases()
, the callback can return anIAPError
if the state isfailed
.Declaration
Swift
public struct IAPError : IAPErrorProtocol
-
The list of error codes that can be returned by the library.
See moreDeclaration
Swift
public enum IAPErrorCode
-
Undocumented
See moreDeclaration
Swift
public protocol IAPErrorProtocol : LocalizedError