Detect re-purchase of in-app purchase - iphone

How can I detect this situation in code:
User purchase a full version with in-app purchase.
User delete the application from iPhone.
User installed the application again
User purchases full version,
My problem is that in testing, I can see a message box saying "you already purchased...", but in the application updateTransactions not called.
In this situation I need to change to full version. How can I detect this event?
I.e., How can I know in my application that the user already purchased so I will "open" to full version?
Thanks.

Use [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]. It will force your app to receive transactions again.
See docs:
Restoring transactions
- restoreCompletedTransactions

Related

Checking And Verify Purchase

I made an app and released it onto the App Store costing $2.99 AUD.
I now want to make it free and block some features for a premium upgrade(In App Purchase) My problem is that I want the users who have already purchased the paid version get an update to the premium version of the free app.
I was wondering if there is a way to verify the user has purchased the in app purchase before on launch of the app and if it comes back saying they have purchased, they get the extra features and if not, they don;t
Is there any way to check or verify purchases??
Thanks
The way to do this is to to check the original application version from the receipt. There is a receipt field called original_application_version. This is the version of the app that was originally purchased. You can check the receipt to see if the original version is from when it was a paid download, and flag that this user is "premium".
Whether you want to do this locally or server side is up to you.
Note that download receipts are not present in Sandbox, but should be in production. So you'll have a receipt even if no in-app purchases have been made. If for some reason there isn't a receipt present on the device, you should have a restore purchases button that will return a receipt where you can check the original application version.

How restoreCompletedTransactions returns product ids,Is its as per apple id or as per application

I am developing a application in which i have 10 items setup for in-app purchase, and also i am giving an option to restore the purchases he made, if user changes his device or may be any possible case.
I want to ask that, if user taps on "restore transactions" button from my application,then Store kit is going to return all the purchases id from his Apple id(that he purchased from other apps also) or it will return only of my application.
From the Test Account it returns only of my application purchases ids,But if i try with my apple id, but its giving me error: "This is not a Test User account.",I guess i cannot test restoreCompletedTransactions in debug mode.
So i wanted to know how its going to return the purchases id if the app is released.
Can any one help me..
Thanx...
It returns only the purchased products that belong to your application both in the sandbox mode and production mode.

Restore previous In-App Purchases in application programmatically after install or update?

We are having the issue that the app we have has an In-App purchase that unlocks some content when it is paid.
The problem is that if you reinstall the app or update it, it will be reinstalled without the unlocked content. The customer will have to go through the buying process again and it will then tell them that they already have purchased the content. Is there any way to avoid this issue so that automatically the purchased content is provided if you have already paid for it?
We have tried asking the user for his Apple ID during launch of the app and retrieve his previous payments from that, but Apple disapproves of the practice.
I may be looking at this at a different, unconventional angle but I am really looking for a widely accepted approach for this kind of thing.
Thanks.
A "Restore Purchases" button calling restoreCompletedTransactions on SKPaymentQueue is the way to go-
We considered checking this call automatically on start, or before giving the user a price for the in-app update, but the prompt for user iTunes details which appears makes this impractical, so the button is the best solution.
For that you should simply call restoreCompletedTransactions of the SKPaymentQueue on startup. That's the way apple suggests.

In App Purchase finished outside of an iPhone app

I am implementing an in app purchase subscription model.
Let's say I have an iPhone 3 user which starts the whole purchase process from my application and then exits the application only to continue and fill his app store credentials outside of my app until he is done with the purchase.
How can my app know that the transaction was made upon launch?
Also in case I do get this info how can I tell it is not an old purchase for an old subscription period which has already expired?
And last but not least in case the device supports multitasking and the purchase was finished while my app was in the background how will I get notified upon returning to the foreground?
Thanks
Roi
Have you read Apple's Documentation - In App Purchase Programming Guide? I believe it answers all your questions.
The - (void)recordTransaction:(SKPaymentTransaction *)transaction method takes care of most of your pains.
Once you properly implement this method,you would just have to check whether the inApp purchase is done.Rest is taken care of by the payment methods.
Thanks

Remove In-App Purchase from free app and increase the price

The current version of an application in the App Store is free and has very limited functionality. An In-App Purchase unlocks everything else.
I have decided to remove the In-App Purchase and just make the application cost the same price as the In-App Purchase did. But if I make the update now, then those users who have the free version but who have not yet paid for the In-App Purchase will get a free update into the full version.
I have removed all traces of my singleton class, PurchaseManager, from the application, so that at this point, when I build/run it, all of the features are unlocked. At this point, how can I make sure that the free-version users don't just ride an update into the full version?
Maybe there's a way to test whether the app is obtained through an update or through a purchase? That way, if it's through an update, I will see if it's the free version w/o the IAP and then force the user to purchase the IAP to continue playing.
Any ideas?
There was a user default that was guaranteed to be set in the first version. If the objectForKey: returned nil, then it was never set which means the first version was never run. In that case, I set YES to the user default for whether the In-App Purchase was purchased.
The above ran only once, which guaranteed that users of the demo continued to use the demo until they bought the In-App Purchase (priced the same as the second version of the game), and that users of the full version from v1.0 had the full version as planned.
Not that easy. Push out a minor update your current app and record the device ids of all those who got the in-app activated.
post a blog on your site asking users to send in their device ids and emails for re-imbursing the cost of the in-app purchase. You can cross verify this from the collected device ids.
I know this is painful. Most people who first released their apps on Cydia and then officially on app store did this. For example, snapture.