Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable restore IAP when same Apple account but different user account in application

In my app I have items to show just for users that are pays for subscription. User can log to app by e-mail and password and can logout and on same device can log different user.

My problem is that Apple Id in phone is still same. So when different user logged in he could restore purchase even that he didn't pay anything.

So my question is how can I fix it? How can I connect Apple account to my custom account? Or at least somehow when trying to restore IAP check that this Apple account already have this subscription but different user was logged in. How other apps do this? Thanks

Edit: I want to use Auto-renewing subscription in my app and I just don't know how to connect it to my custom account system.

like image 730
Libor Zapletal Avatar asked Mar 30 '16 14:03

Libor Zapletal


People also ask

How do I unlink an app from my Apple ID?

On your iPhone, go to Settings, then tap your name. Tap Password & Security > Apps Using Apple ID. Select the app or developer, then tap Stop Using Apple ID.

Can I transfer my app and in-app purchases to a new device?

Provided you are logged in with the same app store account that made the purchase then you can re-download the app onto a new device.


1 Answers

When a user makes an IAP, you will not know the Apple Id used to make the purchase. What you will know, however, is the transaction id for the purchase. What you will want to do store the transaction id of the original purchase with your custom account.

When a user restores, you will determine if the SKPaymentTransaction's originalTransaction's transactionIdentifier matches the custom account. If not, then you can assume this is a different user. You can read more about that here:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html

Note that the receipt contains a field called the original transaction id. This is what you would use for subscriptions to track the original transaction id. This is because each time you auto renew, a new transaction id will be generated for the auto renew. The receipt will actually contain all the purchases.

On your server, you would want to save the original transaction id and potentially the receipt. Essentially the more metadata your store around this, the better off you will be if you have to do any form of double checking transactions.

like image 152
Mobile Ben Avatar answered Oct 05 '22 23:10

Mobile Ben