Knowing, without doing a restore, which IAPs have been purchased - ios

My app has individual non-consumable in-app purchases for sale, plus a "bulk" IAP which contains all the other IAPs at a discounted price. Therefore, before allowing the user to purchase an IAP, I need to know which other IAPs they have already purchased. The only way I know of to get this info is to call restoreCompletedTransactions. But Apple has rejected my app, saying I'm not allowed to call restoreCompletedTransactions before displaying the Confirm In-App Purchase dialog. AFAIK this dialog appears when a purchase is attempted. So I'm stuck. Does anyone have any ideas? Thanks!!

What does your app do once a purchase is made? Surely it sets a flag or 2 to allow additional content to work?
Can you not check for whats unlocked, then you'll know whats been bought.
If not, then simply store a value somewhere when a purchase is made.

I thing you couldnt make yourself clear about what you are trying to do. As I am trying to do the same thing let me explain.
When someone purchases a non-consumable IAP you give them some privileges.
In your case discounts, in my case some extra points.
When you dont know that it is the first purchase of the non-consumable IAP you will always give discounts when user press the buy button. You cant store it in NSUserDefaults or keychain because it wont help if user changes device.
So if user buys the IAP from a device, he gets discounts on that device, its cool but he can do this at every device he logs in with the same account. In order to prevent this you need to know if it is the first purchase or not.
Some can say that you should let him to get discounts. I dont know about what he is thinking but in my case I am giving the points for only once because he can make many points with just changing devices and that would be unfair...
Btw I came up with a solution for this but it is not very useful. You can make a gamecenter leaderboard called Pro Users and when someone buys your IAP you can give 100 points to that leaderboard. After that you can check the users score to see if he bought it already or not ...

Related

In-App-Purchase subscribed state in Swift?

So I have a question about doing an in-app purchase with a subscription in swift. I read at this link: https://www.revenuecat.com/blog/the-ultimate-guide-to-subscription-testing-on-ios#sandbox that you need your app to enter subscribed state. Is this some kind of delegate method or something I call, or does it simply mean that I enable the features? I haven't been able to find much detail on that part. Any guidance would be much appreciated. I do have the in-app purchase dialog appearing and the sandbox account working. I also get the alert saying the purchase was a successful. But even 2 seconds later if I try again it just allows me to purchase again.
By subscribed state they mean that a user still should have access to the content he unlocked with the subscription.
But even 2 seconds later if I try again it just allows me to purchase again.
Unfortunately, it is your responsibility to hide already bought in-app purchases from your users. Although, Apple prevents buying the same subscription again. So, when your first purchases succeeded, the second one should lead to an alert from Apple, that the purchases weren't executed. Otherwise, I assume your purchase logic is faulty.
How do you check the eligibility of your users? Do you validate the receipt locally, or are you using RevenueCat for that?

Can a user purchase a consumable and a non-consumable together?

I'm starting to see developers on IOS implement "if you buy a coin pack you'll also get all ads removed". From my understand of IOS in-app purchase I assume the coin pack as consumables, which would be $0.99, and ads removal as non-consumable, which I assume would be free, but how will I make the transaction? Will I make a payment request for the consumables and non-consumable together?
The simple answer is NO. While it might be possible to add two payments to payment queue in a row, it is important for user to understand that he is buying two products together. If you do addPayment twice, the entire flow will run twice, with alerts nagging the buyer - something that you don't want.
In such a case, you better make it so that consumable purchase unlocks the app so that ads do not appear. Single product - with description stating they got ad-removal as permanent bonus.
The ultimate difference between consumable and non-consumable is simply the fact that you can't restore consumables, so you must find a way to store that consumable somewhere, so your app knows to remove ads in case of device change / app deletion.
When you hear other devs offering similar, they are actually selling just one product at a time.
It is possible to sell >1 quantity of an IAP item, though.

How to detect if user has made any in-app purchases?

My iOS app has in-app purchases (consumable) and shows ads periodically. The idea is to remove ads after user has purchased anything. But in-app items are consumable, so after user re-installs the app, I would be unable to determine if he has purchased anything using [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];, right? And I would bomb him with ads again...
What would you suggest to find out that the user has purchased anything already?
Well when a user re-installs your app (i.e. delete it and install it again) there is no immediate way of knowing what purchases did he made. That's why Apple requires your app to provide a way to restore previous purchases so that when the user performs this operation he restores these purchases for free.
For consumable items you might need to use a server for managing the purchases such that when the app loads it checks with the server which purchases the user has made and immediately enable the relevant content.
I do not know if mandatory but "Remove Ads" IAP should be non-consumable so the user will only need to purchase it once (Otherwise I believe users will complain or just won't buy it).
Some creative ways can be found here : iPhone - in-App purchase consumable correct approach
As an improvement on the situation, you could store the fact that a purchase was made in NSUserDefaults. That won't survive if the user uninstalls and reinstalls the app, but at least it survives if the user buys a new phone and restores a backup to transfer everything to the new phone.
You could have a look at Cloud Kit as well, which would store information per AppleId. It's a bit overkill for the problem, but it means you can use Apple's servers instead of your own for free. There would be a difference that if a user installs your app on six devices, makes a consumable purchase on one device, ads will stop on all of them.

Does Non-Renewing subscription requires a restore button?

My app got rejected because of restore button on non-renewing in app purchase. Do i have to remove restore button ? If i have to do so then how user will restore his purchases.Please help.
Non-renewing subscriptions are consumable. Therefore they cannot be restored. A restore button therefore makes no sense. You also need some kind of authentication/login system for the user. (See below for detailed explanations.)
Sources:
consumable vs. non-consumable in app purchases
non-renewing subscriptions
Update from WWDC2017: In Session #303 App Store Engineer Pete Hare explains at 3:00 that a non-renewing-subscription can be seen as "a consumable product with an expiry date on it"
There has been some debates in the comments wether non-renewing subscriptions are consumable or not, so I want to say something about it. "Consumable" means that you can consume them multiple times. Like "30 minutes of talking" in a voice-over-IP telephony application. On the other hand, there are non-consumables that you can buy only once. Like when you unlock all levels in a game app. You buy it once, and when you reset the device and redownload the app, you should be able to restore the purchase, so that you don't have to pay twice to unlock all levels. Furthermore, if you don't tap the restore-button in this case but just buy the "unlock all levels" package again, it works, but you will not be charged by apple a second time. That's why it is called non-consumable. It's some kind of metapher. An apple is "consumable". Once it is consumed, it is gone. A chair is non-consumable. You have it as long as you don't destroy it or give it away.
So, it makes sense to regard a non-renewing subscription as non-consumable. If you buy it a second time, you shouldn't pay twice, you should just use the old subscription you already have. If you reset the device, you should be able to restore the subscription once you re-download the app. The restoration is just not done by Apple but by the app itself.
I still regard non-renewing subscriptions as consumable though. I use a simple definition of consumable vs. non-consumable: An in-app-purchase is consumable, when, from the point of view of the StoreKit API, it can be purchased multiple times in the same week by the same user. All consumable IAP-items cannot be restored through the StoreKit. All non-consumable IAP-items can be restored through the StoreKit.
So, the developer is himself responsible for restoring the in-app-purchase of a non-renewing subscription, right? No, sorry. How would the app restore the in-app-purchase of a non-renewing subscription? Suppose I have an iPod and I subscribe to 1 month of listening to the Foo-radio. Now I want to also listen to the Foo-Radio on my iPad. Soo, I install the Foo-App on my iPad and tap the "restore" button. Well... what is the "restore" button supposed to do? How can it know if I already have purchased a "Foo"-subscription or not, and how long it will still be valid? Answer: it can not. This approach does not work.
In order for a non-renewing subscription to work, you have to login the user first, to tie the subscription to some online account. Username/Password, Open-ID, Login via Gmail, Facebook, etc. all would work. Then, when the user purchases an n-r subscription you have to store the fact that he subscribed on some server and link it to his account on the server. You also have to prevent the user from buying the n-r subscription when he is not already logged in. Let's continue with my iPod/iPad-example above. I download the app on my iPad, I login with Facebook, and voila, I can use the "Foo"-subscription now. There is no need for a "restore" button, because the app should check at login-time which subscriptions the user has.
There will be some additional problems to deal with. (1) For example, nothing prevents the user from logging in into 200 devices. Here the problem is not a user with 200 devices, but a university with 1000 students where 180 students share the same account. (2) If the server crashes, some people will probably lose their subscriptions. Problem (1) can potentially lead to decreased income. Problem (2) can lead to angry and unhappy customers.
From Apple: "Non-renewable subscriptions. Subscriptions that don’t involve delivering episodic content. Examples include access to a database of historic photos or a collection of flight maps. It’s your app’s responsibility to make the subscription available on all of the user’s devices and to let users restore the purchase. This product type is often used when your users already have an account on your server that you can use to identify them when restoring content. Expiration and the duration of the subscription are also left to your app (or your server) to implement and enforce." [Italics and bold added] https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html
Apple Reviewer's current-similar response about Non-Renewing Subscriptions "Your app offers Non-Renewing Subscriptions and this purchasability type must have its own restoring function - if you have removed it please re-implement it. Furthermore, your app must also offer a function, such as account creation, such that purchases can be tracked across all of a user's devices. Please implement a login feature as well as a restore mechanism prior to resubmitting your revised binary for review."

Auto-renewable subscription and non-consumable IAPs

I have a magazine app, and I want to provide users a one year auto-renewable subscription, and for non-subscribed users, they can use non-consumable IAPs to pay for each issue and then download it. What is the best way to implement it?
For auto-renewable subscription I don't think it's a problem. I can follow the tutorial at http://www.viggiosoft.com/blog/blog/2011/10/29/at-newsstand-and-subscriptions/ to finish this part. But for the non-consumable IAP part, I'm not sure. Do I need to add all the non-consumable IAPs for future issues before I submit the app? If I do this, how could Apple review my IAPs, because the future issues are not prepared at the reviewing time. Or, can I add non-consumable IAPs after my app is published to the App store? For example, every time when a new issue is ready in our server, we add a new non-soncumable IAP in iTC, and also set the product id to the issue in the server. When the non-subscribed user click that issue, the purchase for the specified product id will start. Is it possible?
After some research I found that the best way to implement it is to set up a new non-consumable IAP at each time when you want to publish a new issue.
The only problem is that, each IAP needs to be submitted for review, and before it is approved, the users who try to buy the issue will get an error message: "Cannot connect to the iTunes store". I haven't figured out how to know that the IAP is in review, so I can popup a nicer message like "Issue is review, please wait" other than a confusing error message.
I have a magazine app, and I want to provide users a one year
auto-renewable subscription, and for non-subscribed users, they can
use non-consumable IAPs to pay for each issue and then download it.
What is the best way to implement it?
You should accept your solution, but here is another case, maybe it helps you or others:
The subscribers can have they magazines, which are not in at iTunes Server, but at your hosting. Those magazines not need to bypass the apple review.
It depends whether you want a user to be able to permanently have a record stored in their app receipt of the issues they have bought. You might want this, if you want a user to be able to delete the app, with all associated content, then later re-install the app, and be able to download the specific back issues they purchased previously—all without having any user account on your own server. The use of a non-consumable in-app purchase also enables you to give them access to these issues across multiple devices that are signed in to that Apple ID, again without having to run your own user account-server combination to track purchased issues.
If these features don't matter to you, then there is a solution you could consider that is much simpler where you don't have to keep creating new in-app purchase products. Have a consumable in-app purchase product that is called something like Purchase One Issue. When a person buys this product, they get one credit and they can use this to select the issue they wish to be given access to. Your app then gives them access to that issue. You could also of course reverse this process in the UX: they pick the issue, click buy, you send them into the purchase process for the Purchase One Issue product, and you automatically give them access to the selected issue since they already selected it.
Note: consumable in-app purchases are not stored in the app receipt, so a user couldn't use this approach to 'restore previous purchases'. In scenarios where this is acceptable however, this is a much less labour intensive approach once set up.

Resources