Skip to content

Commit

Permalink
add helper to get error localizedDescription in IAPPurchaseResult
Browse files Browse the repository at this point in the history
  • Loading branch information
iridescent-dev committed May 20, 2020
1 parent 72831b7 commit 8ff235c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Sources/InAppPurchaseLib/Common/IAPCallback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions Sources/InAppPurchaseLib/InAppPurchaseLib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,14 @@ 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)
}


// 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)
Expand Down

0 comments on commit 8ff235c

Please sign in to comment.