Browse Source

Rename receiptRefresh to refreshReceipt.
Add refreshReceipt method on OSX which call exit(173)
Fix merge conflit on verifyReceipt result type

phimage 9 years ago
parent
commit
16aeaab132

+ 1 - 1
SwiftyStoreDemo/ViewController.swift

@@ -79,7 +79,7 @@ class ViewController: UIViewController {
     }
 
     func refreshReceipt() {
-        SwiftyStoreKit.receiptRefresh { (result) -> () in
+        SwiftyStoreKit.refreshReceipt { (result) -> () in
 
             self.showAlert(self.alertForRefreshReceipt(result))
 

+ 1 - 1
SwiftyStoreKit/InAppReceipt.swift

@@ -97,7 +97,7 @@ public enum ReceiptInfoField: String {
     // The receipt for an in-app purchase.
     case in_app
 
-    public enum InApp {
+    public enum InApp: String {
         // The number of items purchased. This value corresponds to the quantity property of the SKPayment object stored in the transaction’s payment property.
         case quantity
         // The product identifier of the item that was purchased. This value corresponds to the productIdentifier property of the SKPayment object stored in the transaction’s payment property.

+ 7 - 7
SwiftyStoreKit/SwiftyStoreKit.swift

@@ -129,18 +129,13 @@ public class SwiftyStoreKit {
         receiptVerifyURL url: ReceiptVerifyURL = .Test,
         password: String? = nil,
         session: NSURLSession = NSURLSession.sharedSession(),
-<<<<<<< HEAD
         completion:(result: VerifyReceiptResultType) -> ()) {
-            InAppReceipt.verify(test, password: password, session: session, completion: completion)
-=======
-        completion:(result: ValidReceiptResultType) -> ()) {
             InAppReceipt.verify(receiptVerifyURL: url, password: password, session: session, completion: completion)
->>>>>>> Use receipt URL enum instead of boolean in verify method
     }
 
-    #if os(iOS)
+    #if os(iOS) || os(tvOS)
     // After verifying receive and have `ReceiptError.NoReceiptData`, refresh receipt using this method
-    public class func receiptRefresh(receiptProperties: [String : AnyObject]? = nil, completion: (result: RefreshReceiptResultType) -> ()) {
+    public class func refreshReceipt(receiptProperties: [String : AnyObject]? = nil, completion: (result: RefreshReceiptResultType) -> ()) {
         sharedInstance.receiptRefreshRequest = InAppReceiptRefreshRequest.refresh(receiptProperties) { result in
 
             sharedInstance.receiptRefreshRequest = nil
@@ -159,6 +154,11 @@ public class SwiftyStoreKit {
             }
         }
     }
+    #elseif os(OSX)
+     // Call exit with a status of 173. This exit status notifies the system that your application has determined that its receipt is invalid. At this point, the system attempts to obtain a valid receipt and may prompt for the user’s iTunes credentials
+    public class func refreshReceipt() {
+         exit(ReceiptExitCode.NotValid.rawValue)
+    }
     #endif
 
     // MARK: private methods

+ 1 - 1
SwiftyStoreOSXDemo/ViewController.swift

@@ -57,7 +57,7 @@ class ViewController: NSViewController {
 
             self.showAlert(self.alertForVerifyReceipt(result)) { response in
 
-                exit(ReceiptExitCode.NotValid.rawValue)
+                SwiftyStoreKit.refreshReceipt()
             }
         }
     }