Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronously load receipt without verification. #74

Closed
joeycarmello opened this issue Aug 28, 2016 · 6 comments
Closed

Synchronously load receipt without verification. #74

joeycarmello opened this issue Aug 28, 2016 · 6 comments
Labels
answered Questions which have accepted answers. area: receipt-validation validating receipts for customer or purchase verification type: enhancement type: question

Comments

@joeycarmello
Copy link

joeycarmello commented Aug 28, 2016

Right now the only way to read receipt data is by calling verifyReceipt, and getting access to the ReceiptInfo in the VerifyReceiptResult.

The issue is that this always make a network call out to Apple, just to read receipt data in a format that I can pass into verifyPurchase. This makes it impossible provide an offline-enabled app with this framework alone. I'm happy to verify the receipt with apple using this technique immediately after purchase, but there is no reason to do it every time the app is launched.

Is it possible to provide an accessor to the current ReceiptInfo data?

@bizz84
Copy link
Owner

bizz84 commented Oct 19, 2016

@joeycarmello Apologies for the late reply.

As the user can make multiple purchases over a time period, you may want to always have the most up to date receipt, which is done with a call to verifyReceipt().

In simple cases where for example you have only one purchase available, you could call verifyReceipt() only the first time that the purchase has completed and store it locally. After that you can just get the receipt from your local storage and verify the purchase even if you are offline.

It is beyond the scope of SwiftyStoreKit to provide a way of storing receipt data in the app. You could do it yourself with the keychain for example.

@bizz84 bizz84 added type: question answered Questions which have accepted answers. labels Oct 19, 2016
@bizz84
Copy link
Owner

bizz84 commented Nov 4, 2016

@joeycarmello version 0.5.4 adds a SwiftyStoreKit.localReceiptData value to access the local receipt.

Note that local receipt verification is not implemented yet. See #101

@bizz84 bizz84 added the area: receipt-validation validating receipts for customer or purchase verification label Nov 5, 2016
@bizz84
Copy link
Owner

bizz84 commented Feb 20, 2017

@joeycarmello does the addition of SwiftyStoreKit.localReceiptData solve your problem?

If this issue is not updated in the next few weeks I will close it. Local receipt verification is tracked here: #101

@BlueMilkApps
Copy link

BlueMilkApps commented Feb 21, 2017

It would be nice if we could get access to this localReceiptData as a Dictionary or ReceiptInfo (just like the AppleReceiptValidator does), so we can easily retrieve the properties in the local receipt. This would solve the need to store any productIds and other properties within the app itself, as we can just read directly from the receipt file using SwiftyStoreKit.

I realize this would involve dragging PKCS #7 parsing into the mix, so if not feasible in this library, one could use something like https://github.com/tikhop/TPInAppReceipt to offset this need for now.

@bizz84
Copy link
Owner

bizz84 commented Feb 24, 2017

@RiverbayChris as I said, this can be retrieved with SwiftyStoreKit.localReceiptData:

extension SwiftyStoreKit {

    // MARK: Public methods - Receipt verification

    /**
     * Return receipt data from the application bundle. This is read from Bundle.main.appStoreReceiptURL
     */
    public static var localReceiptData: Data?
}

You can see how this is used in InAppReceipt.swift and AppleReceiptValidator.swift.

Does this answer your question?

@bizz84
Copy link
Owner

bizz84 commented May 11, 2017

@RiverbayChris @joeycarmello closing this for now. Feel free to reopen if my answer does not work for you.

@bizz84 bizz84 closed this as completed May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Questions which have accepted answers. area: receipt-validation validating receipts for customer or purchase verification type: enhancement type: question
Projects
None yet
Development

No branches or pull requests

3 participants