فهرست منبع

Add applicationUsername support to restore purchases

Andrea Bizzotto 8 سال پیش
والد
کامیت
65d135f182

+ 2 - 2
SwiftyStoreKit/PaymentQueueController.swift

@@ -49,7 +49,7 @@ public protocol PaymentQueue: class {
 
 
     func add(_ payment: SKPayment)
     func add(_ payment: SKPayment)
     
     
-    func restoreCompletedTransactions()
+    func restoreCompletedTransactions(withApplicationUsername username: String?)
     
     
     func finishTransaction(_ transaction: SKPaymentTransaction)
     func finishTransaction(_ transaction: SKPaymentTransaction)
 }
 }
@@ -99,7 +99,7 @@ public class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
             return
             return
         }
         }
         
         
-        paymentQueue.restoreCompletedTransactions()
+        paymentQueue.restoreCompletedTransactions(withApplicationUsername: restorePurchases.applicationUsername)
         
         
         restorePurchasesController.restorePurchases = restorePurchases
         restorePurchasesController.restorePurchases = restorePurchases
     }
     }

+ 3 - 1
SwiftyStoreKit/RestorePurchasesController.swift

@@ -27,10 +27,12 @@ import StoreKit
 
 
 public struct RestorePurchases {
 public struct RestorePurchases {
     public let atomically: Bool
     public let atomically: Bool
+    public let applicationUsername: String?
     public let callback: ([TransactionResult]) -> ()
     public let callback: ([TransactionResult]) -> ()
     
     
-    public init(atomically: Bool, callback: @escaping ([TransactionResult]) -> ()) {
+    public init(atomically: Bool, applicationUsername: String? = nil, callback: @escaping ([TransactionResult]) -> ()) {
         self.atomically = atomically
         self.atomically = atomically
+        self.applicationUsername = applicationUsername
         self.callback = callback
         self.callback = callback
     }
     }
 }
 }

+ 2 - 2
SwiftyStoreKit/SwiftyStoreKit.swift

@@ -107,9 +107,9 @@ public class SwiftyStoreKit {
         }
         }
     }
     }
     
     
-    public class func restorePurchases(atomically: Bool = true, completion: @escaping (RestoreResults) -> ()) {
+    public class func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> ()) {
 
 
-        sharedInstance.paymentQueueController.restorePurchases(RestorePurchases(atomically: atomically) { results in
+        sharedInstance.paymentQueueController.restorePurchases(RestorePurchases(atomically: atomically, applicationUsername: applicationUsername) { results in
         
         
             let results = sharedInstance.processRestoreResults(results)
             let results = sharedInstance.processRestoreResults(results)
             completion(results)
             completion(results)

+ 1 - 1
SwiftyStoreKitTests/PaymentQueueSpy.swift

@@ -35,7 +35,7 @@ class PaymentQueueSpy: PaymentQueue {
         payments.append(payment)
         payments.append(payment)
     }
     }
     
     
-    func restoreCompletedTransactions() {
+    func restoreCompletedTransactions(withApplicationUsername username: String?) {
         
         
         restoreCompletedTransactionCalledCount += 1
         restoreCompletedTransactionCalledCount += 1
     }
     }