diff --git a/Sources/InAppPurchaseLib/Common/IAPCallback.swift b/Sources/InAppPurchaseLib/Common/IAPCallback.swift index a784058..ac65678 100644 --- a/Sources/InAppPurchaseLib/Common/IAPCallback.swift +++ b/Sources/InAppPurchaseLib/Common/IAPCallback.swift @@ -14,6 +14,12 @@ public struct IAPPurchaseResult { public internal(set) var state: IAPPurchaseResultState public internal(set) var iapError: IAPError? = nil public internal(set) var skError: SKError? = nil + + public var localizedDescription: String? { + if skError != nil { return skError!.localizedDescription } + if iapError != nil { return iapError!.localizedDescription } + return nil + } } public enum IAPPurchaseResultState { diff --git a/Sources/InAppPurchaseLib/InAppPurchaseLib.swift b/Sources/InAppPurchaseLib/InAppPurchaseLib.swift index 55ce005..ee8d09f 100644 --- a/Sources/InAppPurchaseLib/InAppPurchaseLib.swift +++ b/Sources/InAppPurchaseLib/InAppPurchaseLib.swift @@ -83,9 +83,6 @@ public extension InAppPurchaseLib { /* MARK: - The protocol that you must adopt. */ public protocol IAPPurchaseDelegate { - // Initialize the IAPPurchaseDelegate instance. - init() - // Called when a product is newly purchased, updated or restored. func productPurchased(productIdentifier: String) } @@ -93,7 +90,7 @@ public protocol IAPPurchaseDelegate { // The default implementation of IAPPurchaseDelegate if no other is provided. public class DefaultPurchaseDelegate: IAPPurchaseDelegate { - public required init(){} + public init(){} public func productPurchased(productIdentifier: String) { // Finish the product transactions. InAppPurchase.finishTransactions(for: productIdentifier)