jinSasaki / InAppPurchase

A Simple and Lightweight framework for In App Purchase (Store Kit 1)
MIT License
288 stars 30 forks source link

Save set of purchased items #27

Closed erf closed 5 years ago

erf commented 5 years ago

Have you considered keeping a set or list of purchased/restored product ids? Also saved to disk. Or is this out of the scope of this library?

jinSasaki commented 5 years ago

@erf The purchased items and the latest status are included in the receipt. You can fetch the items from the receipt.

This library does not support the local receipt validation. (Apple recommends not to make the validation codes open source.) Instead, I plan to support the remote validation via Apple's receipt server in the future.

erf commented 5 years ago

I'm not sure i understand what receipt you refer to, is this part of your lib? Can you give an example?

jinSasaki commented 5 years ago

Each app has a receipt including In-App-Purchase information. Please read Receipt Validation.

erf commented 5 years ago

I will have to read up on it, but is it not possible / simpler for the user to save the purchased items on the device after each Purchase / Restore? So you don't have to fetch them each time?

erf commented 5 years ago

I tried to read up on it, but i can't really wrap my head around it yet. I have previously used something similar to what explained in this tutorial, search for the purchasedProductIdentifiers under the Purchased Items section.

jinSasaki commented 5 years ago

I will have to read up on it, but is it not possible / simpler for the user to save the purchased items on the device after each Purchase / Restore? So you don't have to fetch them each time?

You can also save the purchased information to UserDefaults and any databases if you want. However, you should consider that items are possible to be purchased by the same account in multi devices. So, I think it should not be saved in local databases.

I tried to read up on it, but i can't really wrap my head around it yet. I have previously used something similar to what explained in this tutorial, search for the purchasedProductIdentifiers under the Purchased Items section.

I could not find IAPHelper.swift in the tutorial. Please see the implementation of IAPHelper#purchasedProductIdentifiers and ask the author if you want the details.

erf commented 5 years ago

You can also save the purchased information to UserDefaults and any databases if you want. However, you should consider that items are possible to be purchased by the same account in multi devices. So, I think it should not be saved in local databases.

If you are on multiple devices you would have to either Restore or try to Purchase the items again before saving them locally. It's cool if this also could be fixed, but it seem more like a minor inconvenience, since most people are on one device.

I could not find IAPHelper.swift in the tutorial. Please see the implementation of IAPHelper#purchasedProductIdentifiers and ask the author if you want the details.

Hmm. Not sure what you mean, i was just proposing an example for how it could be done to store the purchases locally. Just search for purchasedProductIdentifiers.

jinSasaki commented 5 years ago

If you are on multiple devices you would have to either Restore or try to Purchase the items again before saving them locally. It's cool if this also could be fixed, but it seem more like a minor inconvenience, since most people are on one device.

It is a minor inconvenience if your app does not need to consider multiple devices. However, this is a library. There are developers who consider the app is run in multiple iPhones, in iPhone and iPad, or in a single device. I think a library should not depend on the app situation. So I have no plan that this library does not consider to purchase in multiple devices as far as Apple allows users to purchase in multiple devices.

I recommend you to fetch information from the receipt if you want to know purchased items.

Hmm. Not sure what you mean, i was just proposing an example for how it could be done to store the purchases locally. Just search for purchasedProductIdentifiers.

Yeah, I found purchasedProductIdentifiers from that post, but purchasedProductIdentifiers is not provided by Apple's StoreKit. It is a property of IAPHelper. The post is not mine, so I do not know IAPHelper.swift implementation.

Does it making sense?

erf commented 5 years ago

So I have no plan that this library does not consider to purchase in multiple devices as far as Apple allows users to purchase in multiple devices.

I understand.

I recommend you to fetch information from the receipt if you want to know purchased items.

I look forwared to helper methods for the Receipt / SKReceiptRefreshRequest.

The post is not mine, so I do not know IAPHelper.swift implementation.

All the relevant code is explained inside the article, you can also download the source code from the bottom of the article if you sign in for a free account.