iOS - Identifying and activating purchases made from the App Store - ios

IAP (Subscriptions) can be purchased from the App Store through IAP Promotions or Offer Codes. In the case where the app is not installed yet, I was wondering how to activate the purchase afterwards.
If the subscription was activated through the App Store or an Offer Code was redeemed in the App Store, is it added to the receipt automatically? I guess so, otherwise I would have to restore the purchase, which I think is wrong.
Since I can not test this use cases from a sandbox account, would be very nice to know about the behaviour in advance. Thanks!

Related

iOS app - Logic to implement for in-app purchases

We have a non consumable IAP in our app which costs €3.49. I have purchased the IAP on my phone ages ago and also tested restore a couple of times and everything works just fine. This morning however, while testing the app, I uninstalled and installed the app from the App Store back on my phone. Instead of tapping 'Restore Purchases', I chose to 'Remove Ads', hence purchase the IAP again. I thought that the SDK(Xamarin.InAppPurchase) itself, would automatically track that I had previously purchased this IAP and it would go through the restore process on its own. However, I was proved wrong since a couple of minutes later, I received an invoice from Apple, that I had purchased the IAP again. I also received a statement from my bank for my purchase.
So my question here is: shouldn't the SDK itself check that the IAP was previously purchased under the Apple ID I was using? Should I amend my code on 'Remove Ads' to firstly go through the restore process and if I get a fail callback then move on to the actual purchase process?
Server side should check if non consumable purchase was made before or not.
In case if you try to buy second time your should get message like this:
"You have already purchased this. Do you want to
purchase this again for free?"
It works for non consumable purchases. Check inside itunesconnect if your app really non consumable, probably you made it consumable by mistake.
Also FYI info from apple communities:
https://discussions.apple.com/thread/5574903

Made In app purchase Using with Device token or Apple ID

I am implementing In-App Purchase in my app and test around the existing apps to get some ideas. But I found a scenario which I am quite confused on it.
I have installed an iOS app and purchased the particular levels. Later I uninstall this app, sign out from existing iTunes store account and sign in again with another apple id, then reinstall that app again (same app). Here i can again i need to purchase the particular levels.But my doubt is In-App purchase method we can use based on the purchase Apple ID or Device token ?
If the user can purchased with Apple ID ,then the user can login with another device they no need to purchased again but one user can purchase app and user can login to another users Devices is the one problem..!why because another users no need to purchase.
And if we set the Device token, based on the in-app purchase user can only login that device only ,they can't login another devices with same Apple ID,here it is a problem.
I am quite confused on it... so is the purchased items tied on device if we use multiple apple ids on same device?
I understand that I can restore my purchased items on different devices using same apple id. But how about multiple apple id on multiple devices? If I have 2 apple id associated on an device, I use one of them purchased item, but later I use these 2 apple id login to another device, am I still need to pay again to download items I have purchased on previous device?
Please let me know if my questions are not clear... I hope someone can give some idea on sharing purchased items against different devices and apple ids.And which one use the in-app purchase.
Any suggestions and comments are welcome. Thanks a lot.
IAPs fall into two categories - consumable, and non-consumable.
Non-consumable purchases (purchase level 10-15 of a game, upgrade to pro, etc) are synced across devices by the system, and are restored by the system. They are tied to the Apple ID.
Consumable purchases (purchase 5 gold coins) are NOT synced or restored. Your application needs to remember that the purchase has been made, and store information about that so that a backup and restore correctly restores the user's state. If the user uninstalls and then reinstalls, they have lost any previous consumable purchases (but they will retain all non-consumable purchases, and your application can query for these). You can, of course, sync all information about consumable purchases to your own server, but you would then need to have the user create an account with you. This would allow you to sync consumables between devices.
The Device ID (which you can't get, anyway) has no relevance.
See https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html for more discussion.
If the IAPs are non-consumables (or autorenewables) they can be 'restored' by the user (i.e. the app would execute a restoreCompletedTransactions or refreshReceipt). I believe that the username/password log-in required to restoreCompletedTransactions (or refreshReceipt) must be the same username/password as the person who downloaded the app onto the device. Given that requirement, I still believe that a single 'purchaser' can share their single purchase of a non-consumable IAP on many devices.

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.

Restoring "remove ads" functionality when using consumable IAP

I'm researching how to properly implement the functionality to remove ads in my app when the user makes any IAP and have that functionality restorable.
The way i'm seeing the first part done is to simply put a value in the user defaults that the user has made a purchase and check it before displaying ad. No problem.
But i don't know how to do the restorable part because all my products are consumables. How can I restore this value when the user reinstalls the app? Because as i understand the only record of a consumable is on the device and cannot be restored by apple correct?
Any help would be greatly appreciated, thanks!
You cannot do this purely through store-kit APIs, as there is no restorable purchase record as you say. I can see a couple of options -
You could enable iCloud for your app and persist data to the user's iCloud account, however this won't work for users who don't have iCloud.
You could have the users register an account on your server and use that to store their purchase history (or provide a Facebook login etc).
If a user deletes and re-installs your app then they need to make another in-app purchase to remove the ads - Profit!

Turning off auto-renewing subscriptings on an iOS device in sandbox

I have set up and tested In-App purchases successfully in sandbox environment. But I have a problem:
In actual In-App purchases, I can turn off auto-renewing subscriptings on an iOS device by following this link http://support.apple.com/kb/HT4098?viewlocale=en_US&locale=en_US
I wonder how I can do the same thing in sandbox environment. I thought we have to sign in App Store to turn off auto-renewing subscriptings, but Test User Account can not sign in App Store. So I think we can not turn off auto-renewing subscriptings in sandbox environment.
If so, I also need a simple explanation why we can not.
Thanks for reading and any help or direction will be appreciated.
Yes. That was my experience as well: that test users can't access the settings page to manage subscriptions in their phone. I think Apple just didn't bother programming this knowing that sandbox subscriptions will just cancel after five repetitions anyway. That automatic cancellation is probably your way to test the scenario where a user cancelled through the App Store.

Resources