tags:

views:

205

answers:

3

We're trying to implement a subscription service with in-app purchase in our app. The problem is our service does not require a user account for the past year of service. Users simply use this service with advertisements shown. We want to give them a subscription where they can buy for say, 3 months to have the advertisement removed.

How can this be done? We'll have to make it a consumable because it is a subscription. But we wouldn't know when the subscription end.

  • We can't save the state locally because the user might reinstall the app
  • We can't save the state on the server and tie it to their device because sometimes the user changes device
  • We don't have a user account to tie the subscription to and we don't want to introduce a user account system which spoils the experience.

Is there some way of associating the purchase with their iTunes account? So that it is carried with them when they reinstall or changes device?

+1  A: 

What about linking it to their Facebook or Twitter account? Then you've turned the "creating an account" bummer into a social networking feature.

EDIT:

What you are looking for is most likely stored in the system-wide Keychain. Unfortunately, the last time I checked there is no developer access available to that system-wide keychain, however I could be wrong. It's probably worth noting you can manipulate your own access groups, see GenericKeychain example for more on that.

slf
A: 

Your question is strange because a purchase IS associated to the iTunes user account. Let's suppose a user removes the app from his phone and reinstall it back again, he's able to get back all his subscriptions (that are stored on apple side in his iTunes account).

This mechanism is described as "Recovering transactions" in the document from apple (and this is up to the application to support and implement it) : http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/StoreKitGuide/MakingaPurchase/MakingaPurchase.html#//apple_ref/doc/uid/TP40008267-CH3-SW2

You'll be able to query the itunes account from the user from your app, and ask "what are the currently bought products from this user ?"

Then, when recovering transactions, you get back the reference to all the SKPaymentTransaction on which you can query for the transactionDate (as a property). This will give you the info WHEN the user has bought your consumable.

From it you can also get the product that has been bought using aPaymentTransaction.payment.productIdentifier

If you know that this product identifier is a subscription for 3 months, you can compare its transaction date of and the current date and check if this is below the 3 months or not.

yonel
From the apple documentatio - "Subscriptions and consumable products are not automatically restored by Store Kit. To restore these products, you must record the transactions on your own server when they are purchased and provide your own mechanism to restore those transactions to the user’s devices."Your method will not work with consumeable. And if you make it a non-consumable, they won't be able to purchase another 3 methods after it expires.
erotsppa
:/ I didn't know that, thanks for highlighting. This complexifies a lot the consumable scenarii.... This means that when you buy several times the same consumable product as in app purchase, you won't get several SKPaymentTransaction instances from apple side ? This is really curious :(
yonel
A: 

You can try using this to acces the iTunesMetadata.plist that has a appleId key containg the applestore id used to download the app.

[NSHomeDirectory() stringByAppendingPathComponent:@"iTunesMetadata.plist"]

Of course this might considered undocumented, and Apple break this with future updates or just reject your app.

mfazekas