How to get some user Information when user buy some items on Apple In app purchase by swift? - ios

I am working an app that has In app purchase function.
And i need some unique user information when they make some purchases in order to store it on my Database for some reason.
So how can i get some info like email,username or userId from the purchased user?
Thanks!

You cannot obtain this information from the Apple purchase flow, so the answer depends on what you are trying to accomplish.
If you are selling a non-consumable item, such as a game unlock, Deepak's solution will work for you -- by providing a "restore" button in you application the user will be able to connect to their iTunes account from any of their devices and re-obtain the item.
If you are selling a consumable item, such as in-game currency, you should have the users register with your backend service and be authenticated when they make their purchase. Once you have verified the purchase you can write it to your database and you will be responsible for restoring their state regardless of the device they log in on.
Note that if you combine these approaches it would be possible, though unlikely, that a user could share a non-consumable purchase by using the same iTunes account but different accounts on your system by performing a Apple restore action. If you are managing your own inventory on a server, I recommend using consumables.
So the short answer is, if you want that information, you have to ask for it from the user.

[Answer is valid if you have users registered with your system]The transactions can be restored based on user who has logged into your system ,please refer to link here then you can map the information from your system to the product you are selling via in-app purchase.

Related

Differentiating two Users for In-App Purchases in Application to Buy Non-Renewable Subscription by different users?

I am implementing In-App Purchases first time in my application and new to In-app purchases Store Kit.
I have few doubts regarding In-app purchases:
What happens if a user purchased a subscription and logged out from the application and another user logs in and trying to purchase the same?
Does iTunes allow the second user to use the First user's purchased product?
If it allows how can we handle the second user's subscription?
What details we will get post Successful/Failed transactions from itunes to save in my database?
For a non-renewing subscription then it is entirely up to you to track expiration and determine what content a user has access to and when.
For example, say your subscription gave access to "the word of the day". If the subscription was active for the month of January, then the user would receive access to new words each day in January. The user should continue to be able to see January's words even after the subscription expires, but no new words.
If they resubscribe in March then they would now get new words throughout March.
You need to track all of this on your server against the user account.
Non-renewable subscription IAPs act much like consumable IAPs. The "Restore purchases" Store Kit function does not restore non-renewable IAP items.
To answer your specific questions:
If a new user logs in to your account system in the app (but the same iTunes account is still active on the device) then a second purchase will succeed and you need to update the subscription start and end dates for the new active account on your server.
You also need to cater for the following:
- The original account logs back in; In this case the original subscription entitlements need to be available
- The original or second account log in to another device; Again, the accounts subscription entitlements need to be available.
No, since non-renewing subscriptions are not restorable, the second user cannot "use" the first user's subscription.
You handle each account in your system independently.
Information about the mechanics of the purchase process are described in the In App Purchase Programming Guide

In-App purchase for different login user in my app

Am creating cloud storage app with multiple user access(like Google Drive app).
I want to add expand storage feature using in-App purchase(1 year validity after that user need to renew).If it is single user i can go with Auto-renewing subscriptions.But i need to provide this feature to each login user.
Can i go with Non-renewing subscriptions
If i use Non-renewing subscriptions,i need to manage subscription date and end date in my DB
If u have any idea please share with me :)
Offering a year of service as a consumable IAP might be a valid solution to your problem, since you want to associate the purchase not with the iTunes user, but the user of your service. The issue with subscriptions is that they need to be restorable across all devices for the iTunes user, which is not what you want -- you don't want someone to auth with your system with a different account and restore subscription. Rather, you want to associate a user authenticated on your system with your content, which you could do through a consumable.
You've probably already looked at it, but Apple's IAP documentation can be found here.

Is it possible to offer Apple's In App Purchases on an app that offers multiple user log-ins

We're designing an iPad app at the moment which offers in-app purchases for non-consumable items.
As the scope of the project has expanded, we want to allow the option to sign in to an account, and then sign out of that account and into another - similar to how one could on an app like the Facebook app.
My question is: is it possible to link Apple's in-app purchases to one of our system's user accounts, so that a User may sign in to a different device and access their purchases, but if another User signs in to my device, they cannot access my purchases (despite the device being signed in to my Apple ID)?
Any suggestions welcome
All completed in app purchases are tied to the Apple ID that was used at the time of the transaction. Since non-consumable in app purchases can only be purchased once, you can't use those. So, the only option would be to use consumable in app purchases and keep track of which system user account made the purchase. You need to store those purchase records on an external server somewhere though, since Apple will have no way of telling you which purchase went to which of your internal users. If you lose that purchase history your users will have to buy the item again, and probably not be very happy.

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.

iOS App rejected due to wrong purchase type

I am stuck with one of the in-app purchase rejection issue in my app and need some help on this.
What this in-app for?
In our app we have options for user to become premium user. A user can become premium user to enjoy some benefits and it is tied to time. There are two in-app products which defines them
One month premium service.
One year premium service.
Since these are time based service, user expects these service should be made available for that user once he/she purchase the product for the specified time, from all his/her other devices. In order to track whether the user is premium service user or not, once the purchase is done, the app writes a entry in server about premium service. So when user uses other device and logs in, he/she can enjoy the premium service without any issues. For this reason I created the above mentioned products as "consumable", thinking that it is controlled by our server there will be no issues. But apple came back with rejection and asked me to change the products to "non-renewing subscription".
Here is what apple says about this
We found that the Purchasability Type for one or more of your In App Purchase products was inappropriately set, which is not in compliance with the App Store Review Guidelines.
"Premium account service for 1 month and 1 year" IAPs are set to Consumable.
However, based on product functionality, it would be more appropriate to use the Non-Renewable Subscription In App Purchase type because the service offered by your application requires the user to make an advance payment to access the content or receive the service.
The Purchasability type cannot be changed once an In App Purchase product has been created. Therefore, you will need to create a new In App Purchase product with the correct Purchasability Type. To create a new In App Purchase in iTunes Connect, go to Manage Your In App Purchases, select your app, and click "Create New". The current product will show in iTunes Connect as "Rejected".
Non-Renewable Subscription content must be made available to all iOS devices owned by a single user, as indicated in Guideline 11.6 of the App Store Review Guidelines:
11.6 Content subscriptions using IAP must last a minimum of 7 days and be available to the user from all of their iOS devices
If you choose to use user registration to meet this requirement, please keep in mind that it is not appropriate to require user registration. Such user registration must be made optional. It would be appropriate to make it clear to the user that only by registering will they be able to access the content from all of their iOS devices; and to provide them a way to register later, if they wish to access the content on their other iOS devices at a future time.
For more information about Purchasability Type, please to refer to the iTunes Connect Developer Guide.
Now I have created new in-app products which are non-renewing. But this works the same way as I mentioned earlier, i.e. the server keeps track of whether user is premium user or not, expiry date. When user goes to other device and does login, the app comes to know whether user is premium or not and based on that app works.
But I have couple of questions on this,
Should I need to provide the "Restore" button in the app? If so what is the purpose and how it works?
Since the user can access this service only after doing login to the app (it is different from app store account). Will these two logins make any issue?
Please share your valuable inputs.
It is highly unlikely that the user will end up in a situation where they won't be able to use your app unless they restore their purchases, however it is still possible. Imagine your server goes down for a day and during that day some user purchases a subscription, gets a new iPhone, installs your app on the new device and then wipes their old iPhone. I can think of a couple of other, equally unlikely, but still possible situations (Apple receipt validation server going down, etc) in which the purchase receipt will get lost in transit. It's best to provide the button, and if Apple thinks that you need it in your app, you will have a hard time convincing them otherwise.
If by "two logins" you mean user having to log in to your system and then log in to the App Store to purchase the subscription, that should not be a problem.
I recommend you make the changes Apple requested to the Purchasability Type and then re-submit. If you need to clarify a lack of a restore button put it in the notes for the reviewer

Resources