开发者

Check if app has been purchased

I am a beginner; I am trying to solve this but am unable to do so.

I have created an app that displays a few options in a table. When the user taps the cell the details of selected option is shown on another page (details are stored in a plist file).

What I want to do is to set it up so that if the user has purchased the app then only the details should be visible, but if the user has not purchased it, the user should be prompted to do so.

I have created a product ID for iTunes Connect and also created a testing account to test the app.

My problem is with the code: how should i check if user has alread开发者_开发问答y made the purchase?


Using NSUserDefaults is the easiest solution.

After a successful purchase:

[[NSUserDefaults standardUserDefaults] setObject:@"purchased" forKey:@"myPaidItem"]; [[NSUserDefaults standardUserDefaults] synchronize];

And when you need to check if the user has purchased the item:

NSString* isPurchased = [[NSUserDefaults standardUserDefaults] stringForKey:@"myPaidItem"];

if ([@"purchased" compare:isPurchased]==NSOrderedSame) { ........ }

Hope that helps


you have to store this information in appContext as a bool if the transaction is OK , boo= true and when he want to buy another time you hve to check the value of boo wich is stored in app Context

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜