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.
-
+
-
+ ++
+ + + InAppPurchase +
++ +++ + ++ + See more ++++Declaration
+++Swift
+
+ +public class InAppPurchase : NSObject, InAppPurchaseLib
+ -
+ ++
+ + + InAppPurchaseLib +
++ +++ + +++The protocol that
+ + See more +InAppPurchase
adopts.++Declaration
+++Swift
+
+ +public protocol InAppPurchaseLib
+ -
+ ++
+ + + DefaultPurchaseDelegate +
++ +++ + +++The default implementation of
+ + See more +IAPPurchaseDelegate
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
+ -
+ ++
+ + + IAPPurchaseDelegate +
++ +++ + +++The protocol that you must adopt if you have consumable and/or non-renewing subscription products.
+ + See more +++Declaration
+++Swift
+
+ +public protocol IAPPurchaseDelegate
+ -
+ ++
+ + + IAPProduct +
++ +++ + +++Undocumented
+ + See more +++Declaration
+++Swift
+
+ +public struct IAPProduct
+ -
+ ++
+ + + IAPProductType +
++ +++ + +++Undocumented
+ + See more +++Declaration
+++Swift
+
+ +public enum IAPProductType
+ -
+ ++
+ + + SKProduct +
++ +++ + ++ + See more ++++Declaration
+++Swift
+
+ +extension SKProduct
+ -
+ ++
+ + + IAPPeriodFormat +
++ +++ + +++Undocumented
+ + See more +++Declaration
+++Swift
+
+ +public enum IAPPeriodFormat
+ -
+ ++
+ + + IAPPurchaseCallback +
++ +++ + +++Undocumented
+ +++Declaration
+++Swift
+
+ +public typealias IAPPurchaseCallback = (IAPPurchaseResult) -> Void
+ -
+ ++
+ + + IAPRefreshCallback +
++ +++ + +++Undocumented
+ +++Declaration
+++Swift
+
+ +public typealias IAPRefreshCallback = (IAPRefreshResult) -> Void
+ -
+ ++
+ + + IAPPurchaseResult +
++ +++ + +++The result returned in the
+ + See more +purchase()
callback.++Declaration
+++Swift
+
+ +public struct IAPPurchaseResult
+ -
+ ++
+ + + IAPRefreshResult +
++ +++ + +++The result returned in the
+ + See more +refresh()
orrestorePurchases()
callback.++Declaration
+++Swift
+
+ +public struct IAPRefreshResult
+ -
+ ++
+ + + IAPPurchaseResultState +
++ +++ + +++The list of the different states of the
+ + See more +IAPPurchaseResult
.++Declaration
+++Swift
+
+ +public enum IAPPurchaseResultState
+ -
+ ++
+ + + IAPRefreshResultState +
++ +++ + +++The list of the different states of the
+ + See more +IAPRefreshResult
.++Declaration
+++Swift
+
+ +public enum IAPRefreshResultState
+ -
+ ++
+ + + IAPError +
++ +++ + +++When calling
+ + See more +refresh()
,purchase()
orrestorePurchases()
, the callback can return anIAPError
if the state isfailed
.++Declaration
+++Swift
+
+ +public struct IAPError : IAPErrorProtocol
+ -
+ ++
+ + + IAPErrorCode +
++ +++ + +++The list of error codes that can be returned by the library.
+ + See more +++Declaration
+++Swift
+
+ +public enum IAPErrorCode
+ -
+ ++
+ + + IAPErrorProtocol +
++ +++ + +++Undocumented
+ + See more +++Declaration
+++Swift
+
+ +public protocol IAPErrorProtocol : LocalizedError
+